Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why doesn't parenting a tool into a character work?

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)

6 comments

0

Clone it to their backpack then force them to equip it

0

How?

0

x = game.ServerStorage["TOOL NAME HERE"]:Clone(); game.Players.Player1.Character.Humanoid:EquipTool(x);

0

Hmm, Tested the code it seems to work

0

No response from asker .. oh well

0

I'm not online 24/7 :/. Anyways, it doesn't work. It works on PlaySolo, but online it does the same thing as before. This is because the wiki says "This item behaves in the same way as parenting a tool to a Player's character." http://wiki.roblox.com/index.php?title=EquipTool

1 answer

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

3 comments

0

It doesn't work. It works on PlaySolo, but online it does the same thing as before. This is because the wiki says "This item behaves in the same way as parenting a tool to a Player's character." http://wiki.roblox.com/index.php?title=EquipTool

0

I don't understand why your script doesn't work I even error checked it, this is most likely a roblox bug and you should report it to info@roblox.com!

0

alright...

This discussion is preserved as it was. New answers, comments, and votes are closed.