Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Decreasing speed when unequipping a tool doesn't work?

Ok so this tool functions like a speed coil (kinda) and I need the speed to be back to normal when the player unequips it but it's not working for some reason? Giving me an error which says:

"UnEquipped is not a valid member of Tool"

local tool = script.Parent.Parent

tool.Equipped:Connect(function() --Will listen for when the player equips the tool then connects to the enclosed function
    local char = tool.Parent --When a tool is equipped it moves from the backpack to the character model
    char.Humanoid.WalkSpeed = 14 --Sets the walkspeed by finding the humanoid that's under the character
end)

tool.UnEquipped:Connect(function() --Will listen for when the player equips the tool then connects to the enclosed function
    local char = tool.Parent --When a tool is equipped it moves from the backpack to the character model
    char.Humanoid.WalkSpeed = 12 --Sets the walkspeed by finding the humanoid that's under the character
end)

1 answer

✓ Accepted answer
local tool = script.Parent

tool.Equipped:Connect(function()
	tool.Parent.Humanoid.WalkSpeed = 14 --when equip tool tool parent is character
end)

tool.Unequipped:Connect(function() 
	tool.Backpack.Parent.Character.Humanoid.WalkSpeed = 12 --When you unequip tool your parent is backpack so parent backpack is player 
end)

1 comment

0

I had to edit your script a bit but it works, thank you kind lad

This discussion is preserved as it was. New answers, comments, and votes are closed.