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

Can someone Help with this welding script?

Asked by 9 years ago

I got the actual welding part down, but how do i make it so the player can move with the part welded to them. This is all done when the player hits a key while the tool is equipped.

tool = script.Parent

player = game.Players.LocalPlayer
stat = "undone"
tool.Equipped:connect(function(mouse)
    mouse.KeyDown:connect(function(key)
        if stat == "undone" then
            stat = "done"

        print(key)
        local head = script.Parent.Parent.Head
        local part = Instance.new("Part")
        part.Parent = game.Workspace
        local w = Instance.new("Weld")
        part.CanCollide = false
        w.Part0 = head
        w.C0 = head.CFrame:inverse()
        w.Part1 = part
        w.C1 = part.CFrame:inverse()
        part.CFrame = head.CFrame * CFrame.new(0,15,0)
        w.Parent = head
        part.Anchored = true
        wait(15)
        stat = "undone"





        end
    end)

end)

So far the actual part goes in the proper position but the player cannot move.

0
Parts must be unanchored if you want to weld them and have them move with the character. Redbullusa 1580 — 9y

1 answer

Log in to vote
0
Answered by
sigve10 94
9 years ago

In the end of the script (between "w.Parent = head" and "wait(15)") you have put "part.Anchored = true", but this would make the part unable to move. If you keep the anchored value False it would make the part movable, and it would still stick to the player. Therefore I would suggest you to change the "part.Anchored = true" to "part.Anchored = false".

I hope this helped

Ad

Answer this question