Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Leaderstats is not a valid member of Player?

The error in the question, is what repeatedly shows up in this script that is supposed to make a player's speed equal to their leaderstats value.

local player = game:GetService("Players").LocalPlayer
local char = player.Character

player.leaderstats.Speed.Changed:connect(function()
    char.Humanoid.WalkSpeed = player.leaderstats.Speed.Value + 16
end)

6 comments

0

Have you tried print debugging?

0

Maybe try adding a wait() to the beginning? Without more details on how leaderstats is being created, I can't help you much.

0

player:WaitForChild("leaderstats"):WaitForChild("Speed").Changed:Connect(function() (make sure that the Speed IntValue is actually in leaderstats, not in the player)

0

I already told him that haha. @iddash. But he's using a serverscript so he shouldn't use localplayer.

0

o kl mb

0

ok so what these comments are telling me is i should try using waitforchild on all of them, make sure int value is in leaderstats, and this is meant to be a serverscript

1 answer

✓ Accepted answer

leaderstats is not yet a member of the player when you are setting an event listener. Add a WaitForChild() to only continue once the value actually exists.

This discussion is preserved as it was. New answers, comments, and votes are closed.