Equipped and Unequipped event being called repeatedly?
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...
07 | local copygun = game.ServerStorage.Remi 700 :Clone() |
09 | gun = copygun:GetChildren() |
10 | for i, v in ipairs (gun) do |
11 | v.Parent = copygun.Parent |
14 | newweld(Handle, tool.reciever, tool.reciever, "gunweld" ) |
15 | player.Torso:findFirstChild( "Left Shoulder" ).Part 1 = nil |
16 | player.Torso:findFirstChild( "Right Shoulder" ).Part 1 = nil |
17 | newweld(tool.Parent.Torso, player:findFirstChild( "Right Arm" ), player:findFirstChild( "Torso" ), "rarmweld" ) |
18 | tool.Parent.Torso.rarmweld.C 1 = CFrame.new( 1 ,. 4 ,-. 3 )*CFrame.Angles(math.pi/ 2 , 0 , 6.3 ) |
19 | newweld(tool.Parent.Torso, player:findFirstChild( "Left Arm" ), player:findFirstChild( "Torso" ), "larmweld" ) |
20 | tool.Parent.Torso.larmweld.C 1 = CFrame.new( 0 ,. 48 ,- 1 )*CFrame.Angles(math.pi/ 2 ,-. 1 , 7 ) |
22 | tool.Equipped:connect(Weld) |