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

Why my model's primary part's position sets to (0,0,0) when I try to set it's CFrame?

Asked by 3 years ago

Hello there.

So I have a simple script that "teleports" the door model to the expected directon. But for some reason, It sets the PrimaryPart position to (0,0,0) automatically. I also don't get any error in output. Can someone explain why this is happening and help me to fix it?

Here's the script that I'm talking about:

while wait() do
    if game.Workspace.ReactorExploded.Value==true then
        script.Parent.DoorScript.Disabled=true
        script.Parent.ClickDetector.MaxActivationDistance=0
        script.Parent.Parent.Parent.Door:SetPrimaryPartCFrame(CFrame.new(-55.04, 21.684, 65.795)) --that's the line that I'm talking about
        script.Parent.Parent.Parent.Door:SetPrimaryPartCFrame(CFrame.Angles(0, 30, 90))
        script.Disabled=true
        break
    end
end
0
dude, don't use cFrame. It confuses people for noo reason. Use the moveTo function for models Xyternal 247 — 3y

1 answer

Log in to vote
0
Answered by
Xyternal 247 Moderation Voter
3 years ago
Edited 3 years ago

So as I said in the comments, DO NOT use CFrame for models, because its really confusing for people like me (I'm a noob with scripting.). Get rid of the line that says

script.Parent.Parent.Parent.Door:SetPrimaryPartCFrame(CFrame.new(-55.04, 21.684, 65.795))

and replace it with the line

 script.Parent.Parent.Parent.Door:MoveTo(x,y,z)

It is easier, and works 95% of the time

0
Didn't work dude, I still have the same problem. But thx for the answer anyway. Va1t_Dev 86 — 3y
0
oof ok. But neil says that there is something wrong in your angel script Xyternal 247 — 3y
0
this may be refering to the object position, that is, the model part's position relative to the model part's root. And of course, a part is where a part is so for the root that would be 0,0,0. Make sure to check if its objectposition first! Just a possibility. MrGreystone 0 — 3y
0
Did I not answer this question in the community chat by simply having CFrame.Angles along with math.rad greatneil80 2647 — 3y
Ad

Answer this question