Orientation not working

When I try changing the orientation of my model it doesn’t work it just resets back in an instant.

I’m trying to create sort of an egg hatching system and rotate the pet when hatched put for some reason it doesn’t want to add to the old rotation it stays still.

I put this into a loop, which doesn’t work

newDumbell:PivotTo(newDumbell:GetPivot() * CFrame.fromEulerAngles(0,math.rad(50),0))

This does work when I do it once:

newDumbell:PivotTo(newDumbell:GetPivot() * CFrame.Angles(0,math.rad(50),0)) -- I changed it to CFrame.Angles

Could you send the entire loop code? This line of code should function as intended if written by itself

Using CFrame.fromEulerAngles without the second argument is equivalent to using CFrame.fromEulerAnglesXYZ, and CFrame.Angles is also equivalent to using CFrame.fromEulerAnglesXYZ, so is there a specific reason as to why you’re using CFrame.fromEulerAngles in the first example? Since CFrame.Angles uses the same rotation order and it’s working correctly for you, you should use it instead

I watched a video on how to do it because mine didn’t work, I copied it.

Doing something like this should work to make newDumbell rotate on the Y axis:

local RunService = game:GetService("RunService")

local RAD_PER_SEC = math.rad(50) -- This will make newDumbell rotate 50 degrees per second

local newDumbell = -- The newDumbell Model
local newDumbellPivot = newDumbell:GetPivot() -- We'll need to store the newDumbell's original pivot


local angle = 0


RunService.Heartbeat:Connect(function(deltaTime: number)
	angle += RAD_PER_SEC * deltaTime

	newDumbell:PivotTo(newDumbellPivot * CFrame.Angles(0, angle, 0)) -- Angle is in radians already, so no need to convert it
end)

Remember to disconnect the heartbeat loop if it’s no longer required :slight_smile::+1:

Now I see it changing, but the dumbbell still doesn’t rotate, It’s located in the players camera and its a local script.

This is my script part now:

local newDumbbellPivot = newDumbell:GetPivot()
	
	dumbbellConnection = runService.Heartbeat:Connect(function(deltaTime: number)
		dumbellAngleAmount += dumbellRotateSpeed * deltaTime
		
		local cf = CFrame.new(0,0,-normalDumbbell.PrimaryPart.Size.Z * 3) * CFrame.Angles(0, dumbellAngleAmount, 0)
		newDumbell:PivotTo(camera.CFrame * cf) -- Angle is in radians already, so no need to convert it
	end)

also it doesn’t change per second when I run it.

I got it to work thank you so much!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.