I'm trying to force a player to equip a tool by simply cloning it from ServerStorage into their Character model. Although this works fine in Play Solo, when I play online it doesn't work. Although the tool does clone into the character model, it appears to not be welded or positioned correctly on the arm. The Handle spawns at a single point in the world, then falls and gets deleted. What can I do to fix this?
Here's the code, although it's really not the problem, you can use it for reference.
local box = script.Parent.SelectionBox local weaponName = script.Parent.Name local weapon = game.ServerStorage:WaitForChild(weaponName) script.Parent.Touched:connect(function(hit) --Check for projectile if not hit or not hit.Parent then return end local chr = hit.Parent local hum = chr:FindFirstChild("Humanoid") if hum and hum.Health > 0 and not chr:FindFirstChild(weaponName) and box.Visible then box.Visible = false local tool = weapon:Clone() tool.Parent = chr wait(5) box.Visible = true end end)
This answer was done with out studio, I will edit this code later when I have studio.
local box = script.Parent:WaitForChild('SelectionBox') -- Wait for it! local weaponName = script.Parent.Name local weapon = game.ServerStorage:WaitForChild(weaponName) script.Parent.Touched:connect(function(hit) --Check for projectile if not hit or not hit.Parent then return end local chr = hit.Parent local hum = chr:FindFirstChild("Humanoid") if hum and hum.Health > 0 and not chr:FindFirstChild(weaponName) and box.Visible then box.Visible = false hum:EquipTool(weapon:Clone()) -- Use this function to equip the tool wait(5) box.Visible = true end end)
I hope this helped : D