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

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

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

1 comment

0

dude, don't use cFrame. It confuses people for noo reason. Use the moveTo function for models

1 answer

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

4 comments

0

Didn't work dude, I still have the same problem. But thx for the answer anyway.

0

oof ok. But neil says that there is something wrong in your angel script

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.

0

Did I not answer this question in the community chat by simply having CFrame.Angles along with math.rad

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