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

Weld script only works for current gun?

Asked by 6 years ago

I am having trouble with this weld script. The script works for the first gun, but when i copy the first gun assets into another, the other gun seems to be glued to the ground. It wont let the player pickup the gun, but when i use the PerfectWeld script, the gun is able to be picked up, but the gun script breaks. Like the Mag wont drop out and it wont reload. i know its this weld script that is part of the main gun script. Its the same when placing the other gun in starterpack.

for i,v in pairs(script.Parent.ExtraParts:GetChildren()) do
    coroutine.resume(coroutine.create(function()
        local weld = Instance.new("Weld", v)
        weld.Part0 = v
        weld.Part1 = script.Parent.Handle
        weld.C0 = v.CFrame:inverse()
        weld.C1 = script.Parent.Handle.CFrame:inverse()
    end))
end

How the script works, is its basically saying all parts that are located in "ExtraParts" folder weld them together. But when it comes to another gun, it ramain in its placed position and wont allow the player to pick it up what might be the cause of this?

Answer this question