0

# Why is my speed tool not working when decreasing speed?

This is the script and it works adding speed but breaks when decreasing

local tool = script.Parent
local Handle = tool:WaitForChild("Handle")

tool.Equipped:Connect(function()
local h = script.Parent.Parent:FindFirstChild("Humanoid")
h.WalkSpeed = h.WalkSpeed + 20
end)

tool.Unequipped:Connect(function()
local h = script.Parent.Parent:FindFirstChild("Humanoid")
h.WalkSpeed = h.WalkSpeed - 20 --Here is the problem. It says that walkspeed is not a valid member of Humanoid
end)


2
local tool = script.Parent

if script.Parent.Parent.Name == "Backpack" then
character = script.Parent.Parent.Parent.Character
else
character = script.Parent.Parent
end

h = character:WaitForChild("Humanoid")

tool.Equipped:Connect(function()
h.WalkSpeed = h.WalkSpeed + 20
end)

tool.Unequipped:Connect(function()
h.WalkSpeed = h.WalkSpeed - 20
end)

0
I believe it is losing the proper humanoid, as when you unequip it, it goes into the player's backpack, and it is looking for the humanoid in the player's backpack. LegoUnicornRoblox 37 — 2y
0
Yep works just fine. Tahnk You stranger HeroFigo 61 — 2y