Did you make the humanoid variable local?
yes in the equipped function like you put it.
I didn’t make it local in the script I sent.
Did you format it like this?
local tool = script.Parent
tool.Equipped:Connect(function()
local humanoid = tool.Parent.Humanoid
humanoid.WalkSpeed = 50
end)
tool.Unequipped:Connect(function()
humanoid.WalkSpeed = 16
end)
This is what you accepted earlier.
I did because I tweaked it a bit
Just keep it a global variable and change the JumpPower to WalkSpeed.
I made it a global variable and it didn’t work at all.
Send the code you have currently
local tool = script.Parent
local humanoid = tool.Parent.Humanoid
tool.Equipped:Connect(function()
humanoid.WalkSpeed = 50
end)
tool.Unequipped:Connect(function()
humanoid.WalkSpeed = 16
end)
This is because you need to define humanoid
inside the Equipped event. When a tool is equipped, the tool becomes a parent of the player’s character, so defining it at the top will not work. By global variable I mean a variable without the local
declaration.
local tool = script.Parent
tool.Equipped:Connect(function()
humanoid = tool.Parent.Humanoid
humanoid.WalkSpeed = 50
end)
tool.Unequipped:Connect(function()
humanoid.WalkSpeed = 16
end)
For some reason once I copied and pasted the code it worked. So I guess that solved it.
That’s because what you sent is not the same as what I sent and I explained what you were doing wrong.
Ok. I’ll keep that in mind next time. Thanks for your help!