How to i make a speed on equip tool?

I’m trying to make a script where once you equip it it, you get more speed. And once you unequipped it, you go back to normal speed.

This is the script I’m using

local tool = script.Parent

local player = game.Players.LocalPlayer

local char = player.Character or player.CharacterAdded:wait()

local human = char:WaitForChild(‘Humanoid’)

tool.Equipped:connect(function()

human.WalkSpeed = 30

end)

tool.Unequipped:connect(function()

human.WalkSpeed = 16

end)

It did not work.

Do you have RequiresHandle enabled in the tool? if there is no handle in the tool and it is enabled, the code will not work.

I tried that, but it did not work.

Can you show a screenshot of the explorer to see where the tool and localscript are placed?

The script is not a local script

You can’t use Players.LocalPlayer in a server-script.

Try this:

local tool = script.Parent

local player = script:FindFirstAncestorWhichIsA("Player") or game:GetService("Players"):GetPlayerFromCharacter(script.Parent.Parent)

local char = player.Character or player.CharacterAdded:Wait()

local human = char:WaitForChild("Humanoid")

tool.Equipped:connect(function()

human.WalkSpeed = 30

end)

tool.Unequipped:connect(function()

human.WalkSpeed = 16

end)

It worked! Thank you a lot! I will make this a solution.

1 Like