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

What's does (attempt to index nil with 'WalkSpeed') mean? Script 4.

Asked by 4 years ago
Edited 4 years ago

It said "Players.tecknobladee.Backpack.TheSwordName.Script:4: attempt to index nil with 'WalkSpeed'" How do I fix it?


script.Parent.Equipped:Connect(function(char) local h = char:WaitForChild("LocalPlayer",10) h.WalkSpeed = h.WalkSpeed * 1.20 end)

2 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

The reason it didn't work, is cause when you Say Char its not the character, its the players mouse

so the solution is easy when you equip the tool, the tool goes into the character so we can say local Character = script.Parent.Parent then we can adjust the walk speed Character.Humanoid.WalkSpeed = Character.Humanoid.WalkSpeed * 1.2

Note: attempt to index nil means that the property you are getting dosn't exist

script.Parent.Equipped:Connect(function(PlayerMouse)
    local Character = script.Parent.Parent
    Character.Humanoid.WalkSpeed = Character.Humanoid.WalkSpeed * 1.2
end)
0
It now says WalkSpeed isn't a valid member of Model Tecknobladee 4 — 4y
0
ok wait asdfghjk9019 225 — 4y
0
fixed asdfghjk9019 225 — 4y
0
try now asdfghjk9019 225 — 4y
View all comments (3 more)
0
script.Parent.Parent isn't character in all cases, you would be better doing game.Players.LocalPlayer.Character karlo_tr10 1233 — 4y
0
i know asdfghjk9019 225 — 4y
0
but what is he uses a script and not local? asdfghjk9019 225 — 4y
Ad
Log in to vote
-1
Answered by
Rynappel 212 Moderation Voter
4 years ago
Edited 4 years ago

Local player is not a member of character character is a member of local player


script.Parent.Equipped:Connect(function(char) local h = char:WaitForChild("Humanoid",10) — I’m assuming char is character h.WalkSpeed = h.WalkSpeed * 1.20 end)
0
The same error message showed up. Tecknobladee 4 — 4y
0
You are assuming wrong, Equipped event returns Mouse parameter karlo_tr10 1233 — 4y

Answer this question