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