I have a server script that runs a function when the players character appearance has loaded.
It takes a new tool from ReplicatedStorage, and clones it. (This function runs, its not a matter of the function not running due to race conditions or anything)
There is an issue with equipping the tool with the players humanoid after cloning, and depending on where you parent the tool before calling :EquipTool(), it may not work, or give strange results?
Some info about the tool:
Handle is required, and it has a part named Handle
All the parts inside are un-anchored, welded together, and have all cancollide/cantouch/canquery turned off
If i parent the tool directly in the players backpack and call :EquipTool() on it, it just stays in the players backpack, it refuses to parent to the players character, and stays put in the backpack. Using an AncestryChanged event, it will fire when its parented to the backpack, but wont fire again because it doesnt move.
local newWateringTool = wateringTool:Clone()
newWateringTool.AncestryChanged:Connect(function()
print(newWateringTool.Parent)
end)
newWateringTool.Parent = player.Backpack
humanoid:EquipTool(newWateringTool)
If i parent the tool into the workspace and call :EquipTool(), it will equip the tool as needed, welds to the players hand and works! But the AncestryChanged event is kind of weird. If i hook up the AncestryChanged event before parenting it to the workspace, it wont fire when its parented to the workspace, and then will fire TWICE when it is added into my character through the humanoid:EquipTool() function.
local newWateringTool = wateringTool:Clone()
newWateringTool.AncestryChanged:Connect(function()
print(newWateringTool.Parent)
end)
newWateringTool.Parent = Workspace
humanoid:EquipTool(newWateringTool)
This code will print lollypop99p (my character) twice in a single frame
The equipping works when pressing “Play” in studio, but if i try local servers, or a full roblox server, it bugs out as described above?
Expected behavior
I want the tool to equip after calling :EquipTool(), especially if it’s already in the players backpack