#Basic player seated code

1 messages · Page 1 of 1 (latest)

iron topaz
#

I am trying to make a code so that when a player is sitting on a seat they get 50 money every 5 seconds I am not sure what code to use could someone please give me an outline of what code lines I should use. I have tried many things it doesn't seem to work

woeful jasperBOT
#

studio** You are now Level 3! **studio

idle mango
#

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

frosty notch
#

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

frosty notch
iron topaz
#

Thanks alot that should help

idle mango
#

@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)
iron topaz
#

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)

idle mango
#

what's the error message

#

i typed it on discord so there could 100% be a typo

burnt berry
#

you can bind an event to a specific property changing?

#

that lowk seems helpful