So this is changing the stats for all players

no output
It is only supposed to change a single persons learderstats when they start walking up stairs, but one person can be walking up the stairs but the leaderstats value change for all players.
local

local toucher = game.Workspace.Step_Givers:GetChildren()

for i = 1,#toucher do
local debounce = false
toucher[i].Touched:Connect(function(hit)
if not debounce then
debounce = true
script.Parent.RemoteEvent:FireServer(hit.Parent.Name)
print(“ADDED”)
debounce = false
end
end)
end

ServerSide With Remote Event

script.Parent.RemoteEvent.OnServerEvent:Connect(function(Player)

local steps = game.Players:FindFirstChild(Player.Name):FindFirstChild(“leaderstats”):FindFirstChild(“Steps”)

steps.Value = steps.Value + 1

end)

You need to verify that the part hitting the stair is a descendant of the LocalPlayer’s character. (in your localscript)

You should also consider having this code solely on the server, as exploits can fire that remote whenever they want and get free steps.

1 Like

So add a if statement like
if hit.Parent = game.Players.LocalPlayer.Character then

???

Yes, that should work (== though, not =). Although I don’t see why your old script would give steps to all players, from the looks of it it would just give too many steps to the player who hit the stair as every client would tell the server to award steps to that player.

1 Like

Yea im also not sure as to why its giving points to other players.

I see why now. It’s because the first argument in the OnServerEvent is automatically assigned to the player who fired the event, and every player would be firing the event in this case. Adding the localplayer check should be enough.

1 Like