Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

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

Asked by 11 years ago
1game.Players.PlayerAdded:connect(function(plr)
2    plr.CanLoadCharacterAppearance=false
3    plr.Character.Humanoid.WalkSpeed=(0)
4    wait(25)
5    plr.Character.Humanoid.WalkSpeed=(40)
6end)

Output:

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

1
try adding a :WaitForChild("Character") after the plr on lines 3+5 FearMeIAmLag 1161 — 11y

1 answer

Log in to vote
6
Answered by 11 years ago

Sorry if this doesn't help.

1wait(0)
2game.Players.PlayerAdded:connect(function(plr)
3plr.CanLoadCharacterAppearance=false
4repeat 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
5if plr.Character:FindFirstChild("Humanoid")then --If script finds Humanoid within Character
6plr.Character.Humanoid.WalkSpeed=(0)
7wait(25)
8plr.Character.Humanoid.WalkSpeed=(40)
9end)
0
I had to edit it a bit, but it worked! Tempestatem 884 — 11y
0
No problem man, I'm glad I could help. ;) TheeDeathCaster 2368 — 11y
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. TheeDeathCaster 2368 — 11y
0
By the way. Instead of repeat wait()until plr.Character use prl.CharacterAdded:wait() Destrings 406 — 11y
0
Ugh, the cringe of my past is real. >.< TheeDeathCaster 2368 — 8y
Ad

Answer this question