Bug regarding a LocalScript contained inside of a tool running twice when equipped instantly after being parented to the Backpack

ToolBug.rbxl (56.1 KB)

I have two tools in ServerStorage. These two tools have an identical LocalScript inside both of them. With a server script, I am distributing these two tools to the player. One of the tools I am equipping for them, instantly after being parented to their Backpack. The tool that gets equipped runs its local script twice, once when it is created and parented to Backpack, the next time when the tool is equipped. I have verified this using prints in the local scripts. This happens 100% of the time. The local script in the tool should only run once, on creation.

Reproduction steps:

  1. Create an empty place
  2. Set SignalBehavior property of Workspace to Default
  3. Create two tools, both with an identical LocalScript with a print inside it to verify that it is running. Put these tools in ServerStorage.
  4. Create a script in ServerScriptService that, within a CharacterAdded event, clones these two tools and parents them to the player’s Backpack. Then, equip one of the tools with humanoid:EquipTool() OR by manually parenting it to their character.
  5. Run a studio test and observe that the output displays 3 prints, rather than the expected 2 prints, as there are only 2 tools being added to your Backpack.

    This is what the output looks like if the bug occurs. I am printing the tool and tool.Parent. The tool that was equipped, Tool2, prints twice, and by the second time it runs it is parented to the character (i.e. when it is equipped).

There are multiple ways that stop the bug from happening which causes the expected behaviour (the localscript inside runs only once):

  1. Include a task.wait() either before creating the tools, or in between creating and equipping.
  2. Setting the SignalBehavior property of Workspace from Default to Deferred.
  3. Simply do not equip the tool for the player (letting them equip it manually).
2 Likes

So sorry for the late response! We’re aware of this issue internally, we’ll update you as soon as possible.

2 Likes

as of now 0/7/06/2024 this hasn’t been fixed yet. I also seem to get the local script to be ran twice