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

Welding parts problem?

Asked by 9 years ago

I have a localscript that duplicates a tool with a weld script in it and gives the tool to a player. Here is the weld script:

local t = script.Parent
local h = t.Handle
local e = {}

for i,v in pairs(t:GetChildren()) do
    if v:IsA("BasePart") then
        local w = Instance.new("Weld", game.JointsService)
        w.C1 = v.CFrame:toObjectSpace(h.CFrame)
        w.Part0 = h
        w.Part1 = v
        table.insert(e, w:Clone())
    end
end

script.Parent.Equipped:connect(function()
    for i,v in pairs(e) do
        v:Clone().Parent = game.JointsService
    end
end)

The script works fine, but the problem is that when the tool is copied into the player's inventory, only certain parts of the tool are welded. Copying and pasting the tool in workspace works perfectly well; it's only putting it in the player's inventory that doesn't make it work properly. Can anybody explain why this is happening?

Answer this question