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

Why does this object go to 0,0,0 orientation in a CFrame animation?

I made a wave, which needs to be turned 90 degrees in order to line up with the rest of the wave. I made all parts in a CFrame animation, but the wave keeps turning back to its original (0,0,0) orientation. I tried the following script, which didn't work...

local Orientation = Vector3.new(90,0,0)

for i = 1,1000 do
	wait(.01)
	Tsunami.CFrame = CFrame.new(StartPosition,Orientation) + Vector3.new(0,0,i*-5,0,0,0)
	
end

2 answers

✓ Accepted answer

Hi Zuru,

I think you're turning the part in the wrong way. You're using the good old lookAt method, where you declare a CFrame and give it two arguments, the position and the position it needs to look at. If you want to turn the part 90 degrees, you need to either change its Orientation, or multiply its CFrame by CFrame.Angles().

###Keep in mind that turning 90 degrees on the X axis won't make the wave face up or anything. That's for the Z axis, if you want to make the wave face up, use the Z axis.

####This Script Assumes The Necessary Variables Have Been Declared

part.CFrame = part.CFrame * CFrame.Angles(math.rad(90), 0, 0);

##Hope I helped and have a wonderful day/night.

Thanks,

Best regards,

~~ KingLoneCat

Use TweenService, this gives help to any object, commonly used to animate.

local t = game:GetService("TweenService")

--do the function?
local goal = {} --Don't forget, add this to your code/script!
goal.CFrame = CFrame.new(POSITION,OF,CFRAME)
local Tsunami = game.Workspace.PARTNAME
Tsunami.CFrame = Tsunami.CFrame
local tween = t:Create(Tsunami, TweenInfo.new(2), goal)
tween:Play()
end

Comment below for any errors.

1 comment

0

Thank you for the answer, I'll try it

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