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

Model:SetPrimaryPartCFrame() failed because no PrimaryPart has been set how do i fix this?

Asked by
Hifived 10
2 years ago
Edited 2 years ago

This is My code

local Case = script.Case:Clone()game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        local Case = script.Case:Clone()
        Case:SetPrimaryPartCFrame(Character.HumanoidRootPart.CFrame)
        Case.Parent = Character


        local weld = Instance.new("ManualWeld")
        weld.Part0 = Case.PrimaryPart
        weld.Part1 = Character.PrimaryPart
        weld.C0 = weld.Part0.CFrame:ToObjectSpace(weld.Part1.CFrame)
        weld.Parent = weld.Part0

    end)
end)
--ERROR ON LINE 4

someone Please tell me how to fix this this was in a katana tutorial by RED plys if that helps.

1 answer

Log in to vote
1
Answered by
imKirda 4491 Moderation Voter Community Moderator
2 years ago

:SetPrimaryPartCFrame moves PrimaryPart of a model to that CFrame and then moves all the other parts of the model to follow the PrimaryPart, without one this function will break since it won't know which part is the main.

local Case = script.Case:Clone()
Case.PrimaryPart = Case. --[[ Some part from the Case model, it can be any part ]]
Case:SetPrimaryPartCFrame(Character.HumanoidRootPart.CFrame)
Case.Parent = Character
0
even if you set PrimaryPart in studio it will be reset after :Cloned imKirda 4491 — 2y
0
also ManualWeld is WeldConstraint these days i believe imKirda 4491 — 2y
0
ok thankyou Hifived 10 — 2y
0
PrimaryParts wont be reseted after Cloning idk where you get that Puppynniko 1059 — 2y
0
i don't get that imKirda 4491 — 2y
Ad

Answer this question