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
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.