Part not rotating correctly

I’m trying to rotate a part using CFrame, however, it never rotates correctly. I’m trying to make it turn 10 degrees on the Y axis, but it always ends up at a random Y orientation. All help is appreciated.

game.ReplicatedStorage["079Move"].OnServerEvent:Connect(function(plr, action)
	if action == "TurnLeft" then
		game.Workspace["079Camera"].RotateBall.CFrame = game.Workspace["079Camera"].RotateBall.CFrame * CFrame.Angles(0, ((game.Workspace["079Camera"].RotateBall.Orientation.Y) + 10), 0)
	end
	
	if action == "TurnRight" then
		game.Workspace["079Camera"].RotateBall.CFrame = game.Workspace["079Camera"].RotateBall.CFrame * CFrame.Angles(0, ((game.Workspace["079Camera"].RotateBall.Orientation.Y) - 10), 0)
	end
end)

why not use hinges? it can rotate parts

I think hinges are just a lot more tricky, especially with placing then and everything.

Try adding a “math.rad()”

game.ReplicatedStorage["079Move"].OnServerEvent:Connect(function(plr, action)
	if action == "TurnLeft" then
		game.Workspace["079Camera"].RotateBall.CFrame = game.Workspace["079Camera"].RotateBall.CFrame * CFrame.Angles(0, math.rad(game.Workspace["079Camera"].RotateBall.Orientation.Y + 10), 0)
	end

	if action == "TurnRight" then
		game.Workspace["079Camera"].RotateBall.CFrame = game.Workspace["079Camera"].RotateBall.CFrame * CFrame.Angles(0, math.rad(game.Workspace["079Camera"].RotateBall.Orientation.Y - 10), 0)
	end
end)


For some reason, it keeps going crazy still. It goes from 90 degrees, to 135, and it just goes crazy like that.

I think it might be the multiplication, because when I remove that, it works perfectly, but now the position of it is set to 0, 0, 0.

Try doing this instead

game.ReplicatedStorage["079Move"].OnServerEvent:Connect(function(plr, action)
	if action == "TurnLeft" then
		game.Workspace["079Camera"].RotateBall.CFrame = game.Workspace["079Camera"].RotateBall.CFrame * CFrame.Angles(0, math.rad(-10), 0)
	end

	if action == "TurnRight" then
		game.Workspace["079Camera"].RotateBall.CFrame = game.Workspace["079Camera"].RotateBall.CFrame * CFrame.Angles(0, math.rad(10), 0)
	end
end)


1 Like