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

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

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

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)

7 comments

0

It now says WalkSpeed isn't a valid member of Model

0

ok wait

0

fixed

0

try now

0

script.Parent.Parent isn't character in all cases, you would be better doing game.Players.LocalPlayer.Character

0

i know

0

but what is he uses a script and not local?

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)

2 comments

0

The same error message showed up.

0

You are assuming wrong, Equipped event returns Mouse parameter

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