Tool .Equipped event spamming (repro)

I honestly don’t know what’s going on here. This code works perfectly fine:

local tool = script.Parent

tool.Equipped:connect(function()
	print("Equipped")
	local instance = Instance.new("BodyForce")
end)

When I equip the tool, it just prints “Equipped” once. However, if I add one line and parent the created body force to the character or any of its descendants (anything other than character, like the workspace, behaves normally), .Equipped is spammed:

local tool = script.Parent

tool.Equipped:connect(function()
	print("Equipped")
	local instance = Instance.new("BodyForce")
	instance.Parent = tool.Parent
end)

That’s a really odd bug o.o [strike]I believe every time a descendant is added to the character while a tool is equipped, the tool thinks it was equipped again?[/strike] Odd – it seems this only happens when the object is parented to the HumanoidRootPart or the character.

This bug has been around for a very long time now actually. Certain things when equipped trigger the equipped event for some reason. Until it is finally fixed, you can create a separate thread to counter this issue. That, or you can simply incorporate a delay, though I don’t recommend that.

Try something like this:

Tool.Equipped:connect(function()
Spawn(function()
--Stuff here
end)
end)

Or you could just do a debounce?

This happens, in my experience, whenever you try to edit any character welds inside the Equipped event. Since the event is tripped, I believe, by the addition of a weld to the character (the grip weld). I’ve experienced this problem as well and I typically do something along these lines:

Equipping = false

function onEquip()
 if Equipping then return end
 Equipping = true

 --do stuff

 Equipping = false
end

I normally do use a debounce catch, but I saw this more as a bug than a necessary evil in the tool code that had to be worked around.

[quote] This happens, in my experience, whenever you try to edit any character welds inside the Equipped event. Since the event is tripped, I believe, by the addition of a weld to the character (the grip weld). I’ve experienced this problem as well and I typically do something along these lines:

[code]
Equipping = false

function onEquip()
if Equipping then return end
Equipping = true

–do stuff

Equipping = false
end
[/code] [/quote]

Even that doesn’t work for me sometimes. It’s really annoying.

This happened with my EDM gun a while back, thought I was losing my mind.

In the end, I setup a debounce to prevent it from firing over and over again.