Lately I've been forced to use debounce in my tools because for some reason, the tool calls a function connected to the Equipped/Unequipped event like a thousand times. I thought it was supposed to be called only once.
Should this be happening? Or is this an error on Roblox's side?
Here is part of the script. I kinda don't think it's something I did in the script though.
Edit1: It seems like it ONLY occurs on this tool. I just tried another tool, and it didn't excessivley call the function like this tool did.
Edit2: I think I found the source of the problem. When I cloned Remi700 from ServerStorage, it glitches the entire script. Roblox bug?
Edit3: It seemed to solve the problem when I put a wait() in there. I still don't know why this happened...
--Here are two things you should know.
--All variables are defined.
--newweld() is a welding function that works 100%.
--The problem is ONLY the equipped/unequipped events being called multiple times.
function weldarms()
local copygun = game.ServerStorage.Remi700:Clone()
copygun.Parent = tool
gun = copygun:GetChildren()
for i, v in ipairs(gun) do
v.Parent = copygun.Parent
end
copygun:Destroy()
newweld(Handle, tool.reciever, tool.reciever, "gunweld")
player.Torso:findFirstChild("Left Shoulder").Part1 = nil
player.Torso:findFirstChild("Right Shoulder").Part1 = nil
newweld(tool.Parent.Torso, player:findFirstChild("Right Arm"), player:findFirstChild("Torso"), "rarmweld")
tool.Parent.Torso.rarmweld.C1 = CFrame.new(1,.4,-.3)*CFrame.Angles(math.pi/2,0,6.3)
newweld(tool.Parent.Torso, player:findFirstChild("Left Arm"), player:findFirstChild("Torso"), "larmweld")
tool.Parent.Torso.larmweld.C1 = CFrame.new(0,.48,-1)*CFrame.Angles(math.pi/2,-.1,7)
end
tool.Equipped:connect(Weld)

1 comment
Use Debounce or wait like @Kozero said