#Basic player seated code
1 messages · Page 1 of 1 (latest)
** You are now Level 3! **
Give money to seat.Occupant every 5 seconds
I want to say occupant is a humanoid, so your setup to give 50 money to them would be something like:
local player = game.Players:GetPlayerFromCharacter(seat.Occupant.Parent)
player.leaderstats.money.Value += 50
Something like what hero said but dont forget to include task.wait(5) 🫡🫡🫡🫡 (im assuming you alr know this but jus sayin)
I will do the code when i get home and send you it with full explanation
Im at skl rn
dont spoon feed
Oh okay
Thanks alot that should help
Yeah for the wait keep the normal task.wait() but for your logic you should spawn a separate while loop that waits for 5
@iron topaz
Since if you just task.wait(5) it won’t be smooth on the first payout, for example they could sit with 1 second left on the timer
I’ll hop on my computer in a sec and show you how I’d do it
local seat = (your seat obj)
seat:GetPropertyChangedSignal("Occupant"):Connect(function() --see when occupancy status changes
if not seat.Occupant then return end --exit if there is not occupant
local player = game.Players:GetPlayerFromCharacter(seat.Occupant.Parent)
task.spawn(function() --multithread the function, in case you want to adjust the script for multiple seats
while seat.Occupant do
task.wait(5)
player.leaderstats.money.Value += 50
end
end)
end)
thanks
It doesnt work for some reason and I am using this exact script local seat = script.Parent
seat:GetPropertyChangedSignal("Occupant"):Connect(function() --see when occupancy status changes
if not seat.Occupant then return end --exit if there is not occupant
local player = game.Players:GetPlayerFromCharacter(seat.Occupant.Parent)
task.spawn(function() --multithread the function, in case you want to adjust the script for multiple seats
while seat.Occupant do
task.wait(5)
player.leaderstats.yuan.Value += 50
end
end)
end)