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

How do I correctly use CFrame.Angles() ?

So I'm trying to create a giant fan script with a Union as the fan and a part that the union is welded to. I have made sure that the Union is not anchored. When using:

local rotation = 0
while wait() do
script.Parent.Main.CFrame = CFrame.new(
script.Parent.Main.CFrame.X, 
script.Parent.Main.CFrame.Y, 
script.Parent.Main.CFrame.Z) * CFrame.Angles(0, math.rad(90), 0)
	
rotation = rotation + 1	
end

Nothing happens, but that part is fine. What the issue is is that if I change any of the X or Z values to get the fan to rotate (it's vertical) it will just spin on a horizontal axis. Any idea why (or if I'm just using CFrame.Angles wrong)?

4 comments

0

Is the part anchored?

0

Yes

0

Anchored parts can't be CFramed. Try unanchoring right before you change the CFrame and then reanchor it right afterwards.

0

@radiant_Light that is not correct at all.. You can change CFrame of anchored parts

1 answer

You have 2 options here

-- One of them is;
local rotation = 1
while true do
  wait()
  script.Parent.CFrame  = script.Parent.CFrame * CFrame.Angles(0,math.rad(1), 0)
  rotation += rotation -- += feature was added, yes!
end
-- Second option is probably easier.
while true do
  wait()
  script.Parent.CFrame = script.Parent.CFrame * CFrame.fromEularAngles(0,1,0) -- Rotating the --part without the need of a variable
end

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