Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 9 years ago

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)
0
Clone it to their backpack then force them to equip it DewnOracle 115 — 9y
0
How? ZeptixBlade 215 — 9y
0
x = game.ServerStorage["TOOL NAME HERE"]:Clone(); game.Players.Player1.Character.Humanoid:EquipTool(x); DewnOracle 115 — 9y
0
Hmm, Tested the code it seems to work RM0d 305 — 9y
View all comments (2 more)
0
No response from asker .. oh well DewnOracle 115 — 9y
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 ZeptixBlade 215 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

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

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 ZeptixBlade 215 — 9y
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 ! TheDarkOrganism 173 — 9y
0
alright... ZeptixBlade 215 — 9y
Ad

Answer this question