ServerScriptService
local player = game.Players.LocalPlayer
local player2 = player.Character.Humanoid
while wait() do
player2.WalkSpeed = 16 + player.leaderstats.Cash.Value
end
ServerScriptService
local player = game.Players.LocalPlayer
local player2 = player.Character.Humanoid
while wait() do
player2.WalkSpeed = 16 + player.leaderstats.Cash.Value
end
You should give the game a few seconds to load the character. It shows as nil because the character probably hasn't loaded in yet. Try adding a wait(2) at the beginning of your script.
It's still giving out the same error.
I found your issue! You can't use LocalPlayer in a server script. You need to get the player using another method like an event. Here's an example of an event you could use: game.Players.PlayerAdded
Character is not a valid member of RBXScriptSignal (line 2), am I missing something?
The humanoid probably has not loaded in yet, instead of using:
local player2 = player.Character.Humanoid
Try using:
local player2 = player.Character:WaitForChild('Humanoid')
It's still giving out the same error.
The problem is you're using LocalPlayer in a serversided script. LocalPlayer is only available for LocalScripts, so convert your serversided script into a local script and you'll be fine.
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
If this is a local script, why is it in ServerScriptService?
It's a regular one.