Is there a better way to add WalkSpeed with Equipped And Unequipped Functions

So i was wondering if there was a better way to add Walkspeed with Equipped And Unequipped Functions on server scripts

i wanted to do something like this, so a can add and remove Walkspeed instead of setting it to a number and back but when you spam equip the tool it just keeps stacking on the Walkspeed and doesn’t remove it

image_2023-09-19_192144194

You should change .WalkSpeed += 2 to .WalkSpeed -= 2 in the unequipped event which removes the walkspeed instead of adding it.

Tool.Unequipped:Connect(function()
	Character.Humanoid.WalkSpeed -= 2
end)

Adding on I’m pretty sure that you could do (for the unequip)

Character.Humanoid.WalkSpeed = 16

For the equip:

Character.Humanoid.WalkSpeed = 18

Not sure if this is simpler but it makes more sense to me :person_shrugging:

If you spam equip and unequip it could give you a permanent increase or decrease. You should use set values.

I don’t believe this is possible? Unequipped always runs whenever a player unequips voluntarily or forcefully and it’s the same case for Equipped. I don’t think the engine “skips” one of these signals if you spam it.
However, that can happen if the player has a walkspeed below the amount removed, which actually causes permanent speed loss

If you don’t wan the player to spam it, you can a cooldown

Local cooldown = false

Tool.Equip:Connect(Function()
If cooldown == false then

Character.Humanoid.WalkSpeed += 2
cooldown = true
Wait(5)
cooldown = false

Else
return
end
end)

That is kind of tedious to do, it shouldn’t take so much code for a simple task.

Just wanna put everything everybody said together (There are many ways but this is what I would do)

Local cooldown = false

Tool.Equipped:Connect(function()
	if cooldown == false then
		Character.Humanoid.WalkSpeed = 18 -- Whatever speed you want (normal is 16)
		cooldown = true
		wait (3) -- Whatever cooldown you want
		cooldown = false
	end
end)

Tool.Unequipped:Connect(function()
	Character.Humanoid.WalkSpeed = 16
end)

Pls correct me if this actually doesn’t work (I’m a modeler not a Scripter)

that was just a typo on my part, but i did fix it later but im still having a issue with the spamming part

i would use this type of way but im trying to make it so i don’t have to set a walkspeed by what i mean is im not trying to do (Character.Humanoid.WalkSpeed = 16), im trying to figure out a way i could do (Character.Humanoid.WalkSpeed =+ 16) with the plus without it stacking on walkspeed

Well I’m a idiot, after researching i figured out the reason why the Walkspeed was stacking was because i had a :WaitForChild line above it… :skull:

I’m truly sorry for wasting all your guys time, also thanks for the help and trying

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.