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

Model:SetPrimaryCFrame() failed because no PrimaryPart has been set?

Asked by
imaA6D 39
4 years ago
Edited 4 years ago

I don't understand this error, nor do I know how to fix my script. I tried finding ways to fix this for nearly 3 hours and got nothing. Any help please?

Full Error: Model:SetPrimaryCFrame() failed because no PrimaryPart has been set, or the PrimaryPart no longer exists. Please set Model.PrimaryPart before using this.

01local test = part.CFrame
02 
03car:SetPrimaryPartCFrame(test)
04 
05local pos = test * CFrame.Angles(0, math.rad(180), 0)
06 
07car:SetPrimaryPartCFrame(pos)
08 
09 
10car:MakeJoints()

1 answer

Log in to vote
1
Answered by
Sparks 534 Moderation Voter
4 years ago
Edited 4 years ago

You are using Model:SetPrimaryPartCFrame() before setting the PrimaryPart. Models have a PrimaryPart property, which you need to set before calling methods like SetPrimaryPartCFrame and MoveTo() on the model.

01local test = part.CFrame
02 
03car.PrimaryPart = primaryparthere
04 
05car:SetPrimaryPartCFrame(test)
06 
07local pos = test * CFrame.Angles(0, math.rad(180), 0)
08 
09car:SetPrimaryPartCFrame(pos)
10 
11 
12car:MakeJoints()

You need to replace "primaryparthere" with a part that the rest of the model will use as a basis for positioning. Preferably, this is a part at or near the center. I usually set an invisible part in the center as the PrimaryPart.

0
If the car is cloned from elsewhere, you can set its PrimaryPart in the Property editor on Studio. Sparks 534 — 4y
0
Thanks man imaA6D 39 — 4y
Ad

Answer this question