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

How do I weld something to a specific place on the player?

Asked by 2 years ago

I have here my weld script but It doesn't weld the part to the specific place I want it to. What could I add to my code to make this work?

game.Players.PlayerAdded:Connect(function(Player) -- Player
    Player.CharacterAdded:Connect(function(Char() -- Character
        local Head = Char.Head -- Character's Body Part
        local Part = game.Workspace.Part -- Directory To Part To Weld
        local Weld = Instance.new('Weld', Head) -- Create Weld
        Weld.Part1 = Part
        Weld.Part0 = Head
    end)
end) -- End

2 answers

Log in to vote
0
Answered by 2 years ago

You could change the position of the part before the weld relative to the head. For example if you want to have the part one stud above the head

Part.Position = Head.Position +Vector3.new(0,1,0)
0
That didn't work for me, could you expand on your script? baconbroforpresident 7 — 2y
Ad
Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

A weld has a C0 and C1 property. Which you can read about here: https://developer.roblox.com/en-us/api-reference/class/Weld

If you know the offset you could simply do this:

weld.C0 = offset

If you want to find the offset, use the command bar and do:

print(part0.CFrame:ToObjectSpace(part1.CFrame))

Answer this question