Oh right, I forgot it’s repeat until not do until, my bad. But was the code you had before giving you 10 cash since if it didn’t, it could be that that the child added wasn’t a player
Using a remote event in the local to :FireServer() and on the server [EventLocation].OnServerEvent:Connect(function(player)
In there you can add player.leaderstats.Cash.Value += 10
So it would look something like on the Server:
[DefineEventLocation].OnServerEvent:Connect(function(player)
-- You can add some if statements to make sure the player is not exploiting
player.leaderstats.Cash.Value += 10
end)
Then I believe what you should do is check whenever a palyer sits down, you can do this via Seat.Occupant, which has a value whenever someone sits down, which is their humanoid. It’s set to nil if no one is sitting or has gotten up. You can try
local seat = script.Parent
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
local human = seat.Occupant
if human then
local plr = game.Players:GetPlayerFromCharacter(human.Parent)
if not plr then return end
plr.leaderstats.Cash.Value += 10
end
end)
And also, you got taht error because a child was added to the seat that wasn’t a player, it’s better to check the Occupant instead
Edit: Added a check so it wont try to give money to something that isn’t the character of a player
Oh right, I forgot to add that functionality, use this
local seat = script.Parent
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
local human = seat.Occupant
if human then
local plr = game.Players:GetPlayerFromCharacter(human.Parent)
if not plr then return end
repeat
plr.leaderstats.Cash.Value += 10
wait(1)
until not Seat.Occupant
end
end)
Glad it worked out in the end! Again, make sure to set my reply as the solution for anyone that may see this who’s having a similar issue! Once again, if you have anymore issues, don’t hesitate to make another post!