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

CFrame isn't working to change orientation?

Asked by 3 years ago

I'm having a problem with this script. No errors, nothing. It just doesn't work.

I know absolutely nothing about Cframe rotation, so this script probably isn't optimal.

if script.Parent.Roof.Position.Y < 30 then
    script.Parent:SetPrimaryPartCFrame(CFrame.new(script.Parent.Roof.Position.X, script.Parent.Roof.Position.Y, script.Parent.Roof.Position.Z) * CFrame.Angles(0, 0, 0))
else
    script.Parent:SetPrimaryPartCFrame(CFrame.new(script.Parent.Roof.Position.X, script.Parent.Roof.Position.Y, script.Parent.Roof.Position.Z) * CFrame.Angles(0, 0, math.deg(10)))
end

1 answer

Log in to vote
0
Answered by 3 years ago

If you want your part to rotate constantly, then this is the way to go:

local speed = 0.1 -- Smaller number makes greater spin speed.

local X = 1
local Y = 1
local Z = 1

while true do
script.Parent.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(X,Y,Z)
wait(speed)
end

This particular script will make it spin in all directions. If you only want it rotating in one direction, or on one axis, first change y and z to 0 but keep x to 1, and run the game. If that doesn't rotate the correct direction, then do it with y only being 1 and the rest being 0, and I think you get the point. Hope this helps! (Put in normal script.)

Ad

Answer this question