Equipped item gives player inc. speed

Hi all,

So i want to this item to increase the players running speed. Now i got this little script that does the trick but… when i switch (or take off) the equipped item it still gives me the boost. Any body knows in wich direction to look for a solution?

If the item gives +5 walkingspeed on equip, i want to do it -5 on unequip.

local char = script.Parent.Parent

local hum = char:FindFirstChild("Humanoid")

hum.WalkSpeed = hum.WalkSpeed +5
1 Like

You’ve answered your question yourself already. Using tool events .Equipped and .Unequipped, you can change change walk speed this way:

local Players = game:GetService("Players")

local character = Players.LocalPlayer.Character or Players.LocalPlayer.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

script.Parent.Equipped:Connect(function()
	humanoid.WalkSpeed += 5
end)

script.Parent.Unequipped:Connect(function()
	humanoid.WalkSpeed -= 5
end)

This script should be put in local script and belongs inside a tool. In case your tool doesn’t have a handle, you have to uncheck the “Requires handles” property.

1 Like

thanks alot for your reply, but i get this error

Players.partytonic.Backpack.Mountain Dew.Script:3: attempt to index nil with ‘Character’ - Server - Script:3

i put the script inside the tool (mountain dew)
_r4_c6

Use a LocalScript - not a Script.

maybe it’s not getting the player correctly? I’m not sure. I believe you can grab the player from the Equipped function.

Im sorry, mis readed that one. that did the trick! thank you!