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

Why is this welding script not working right?

Asked by 9 years ago

Here is a video of my problem: https://www.youtube.com/watch?v=OMGrSOQVkxY

In the video, I have a sniper rifle model I buy and clone via a surface gui. The problem is that the welding messes up. For every other gun, the welding script works fine. It's just this gun that doesn't work properly.

And yes, I unanchor the model.

Here's the actual welding 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)

If the script works for every other gun, why isn't it working for this one?

EDIT: I made another video to help solve my problem: https://www.youtube.com/watch?v=_WSd544H_Fs&feature=youtu.be

In this video, I clone the sniper and put its parent to Workspace. That's it. Then, I unanchor both sniper rifles. You'll notice the original sniper stays in-tact while the other falls right through the floor.

Answer this question