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

How does Roblox choose which part teleports to which when welding?

Asked by
Z_DC 104
6 years ago

I've been messing around with welding in Roblox and wanted to weld a player to another player. The goal was to make the player be able to take the other player and hold him.

When welding two parts together, 1 of the parts has to teleport to the other to make them in the relative positions, but I don't understand how Roblox chooses which part to move and which to keep stationary.

As far as I've tested, it seems as the instance that is created earlier is the one that teleports to the one created later on, as Player1 teleports to Player2 when the weld is created no matter which part is Part0 and which is Part1.

I wish to know if there is a way to control this, can anyone help?

Here's some code that simply welds the two players together.

char is the player that I wish to keep stationary while target is the one I wish to move around.

local weld = Instance.new("Weld", char.Torso)
weld.Name = "Detaining Weld" 
weld.Part0 = char.Torso
weld.Part1 = target.Torso
weld.C0 = CFrame.new(0,0,-2.5)
weld.C1 = CFrame.new(0,-.3,0)

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Get rid of C0, only use C1.

local function makeWeld(p0, p1)
    local newweld= Instance.new("Weld") 
    newweld.Part0 =p0
    newweld.Part1 = p1
    newweld.C1 = CFrame.new(0,0,-3.5)
    newweld.Parent = p0
    return newweld
end
0
Didn't work Z_DC 104 — 6y
Ad

Answer this question