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

I don't understand why this doesn't work, can someone tell me why it isnt working?

game.Players.PlayerAdded:connect(function(plr)
	plr.CanLoadCharacterAppearance=false
	plr.Character.Humanoid.WalkSpeed=(0)
	wait(25)
	plr.Character.Humanoid.WalkSpeed=(40)
end)

Output:

Workspace.Script:3: attempt to index field 'Character' (a nil value)

1 comment

1

try adding a :WaitForChild("Character") after the plr on lines 3+5

1 answer

✓ Accepted answer

Sorry if this doesn't help.

wait(0)
game.Players.PlayerAdded:connect(function(plr)
plr.CanLoadCharacterAppearance=false
repeat wait(0)until plr.Character --I usually use that because it will repeat wait(0) until the player's Character has loaded or exists finally, until then the script probly wont go on
if plr.Character:FindFirstChild("Humanoid")then --If script finds Humanoid within Character
plr.Character.Humanoid.WalkSpeed=(0)
wait(25)
plr.Character.Humanoid.WalkSpeed=(40)
end)

5 comments

0

I had to edit it a bit, but it worked!

0

No problem man, I'm glad I could help. ;)

0

I added a wait(0) at the top as you can see, waits 0 seconds before loads, I do that for some of my scripts because there is a coding glitch out there where it wont work without a wait(0)at the top, I also used the 'repeat' to repeat waiting until the player's Character exists, and last but not least the 'if' statement is there to check if Humanoid exists.

0

By the way. Instead of repeat wait()until plr.Character use prl.CharacterAdded:wait()

0

Ugh, the cringe of my past is real. >.<

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