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

Weld Script "Works" On Players; but Position is wrong on NPCs?

Asked by 7 years ago

The weld script that I made for my tools works for players; but on npcs;some of the parts get moved to the 0,0,0 of the Handle instead of going to the proper position.

--Declare Table
local parts = {} 

--Grab Parts
local handle = script.Parent.Handle
local children = script.Parent:GetChildren()
for idx,child in ipairs(children) do
    if(child.ClassName == "Part")then
        table.insert(parts,child)
    end
end

--Weld
for key,value in pairs(parts) do
    local handle = script.Parent.Handle
    if(parts[key] ~= Handle) then 
        key = Instance.new("ManualWeld", handle)
        key.Part0 = handle
        key.Part1 = value
        key.C1 = value.CFrame:inverse() * handle.CFrame
        value.Anchored = false
    else
        value.Anchored = false
    end
end

Can someone tell me why this only affects some parts on NPCs specifically?

Answer this question