Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Main part doesn't move but the rest does?

So I made a model that attaches to a player using primary part. But everytime I run the game only the parts that are in the model moves not the primary/main part. The primary part just stays on the upper torso. I don't know what I am doing wrong. I am new to cframe so can anybody help me please!

local Lighting = game.Lighting
local Vest = Lighting:WaitForChild("Flak Jacket")


game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("UpperTorso")
		
        local ClonedVest = Vest:Clone()
        ClonedVest.Parent = character

        ClonedVest:SetPrimaryPartCFrame(character:WaitForChild("UpperTorso").CFrame)

        local Weld = Instance.new("Weld")
        Weld.Part0 = ClonedVest.Main
        Weld.Part1 = character:WaitForChild("UpperTorso")
        Weld.Parent = character:WaitForChild("UpperTorso")
        ClonedVest:SetPrimaryPartCFrame(ClonedVest:GetPrimaryPartCFrame() * CFrame.new(0,0,5))
    end)
end)

Thanks.

1 answer

I will caution that this is only a hypothesis.

When you make a new weld, its c0 and c1, which are the values that help determine where the parts in the weld go in relation to each other, are all set to CFrame.new(0,0,0). This means the weld is instructed to move both parts to match each other's CFrame. As a result, when you call the next SetPrimaryPartCFrame, the weld brings the primary part back to the upper torso.

If you want to move the primary part, you will have to get rid of the weld or change the weld's CFrame.

For more reading on welds: https://developer.roblox.com/en-us/api-reference/class/Weld

2 comments

0

do i position it before i weld it?

0

You have to manually set the weld's c1 and c0 properties. Try removing the setprimarypartcframe and instead set weld.c1 to CFrame.new(0,0,5) and see if that gets the result you are looking for.

This discussion is preserved as it was. New answers, comments, and votes are closed.