How to make rotation relative to work


UIS.InputBegan:Connect(function(input, gpe)
	if UIS:IsKeyDown(Enum.KeyCode.R) then
		local Oval = game.Workspace.Ignore:WaitForChild("SelectBox").OrientationVal
		Oval.Value = Vector3.new(Oval.Value.X, Oval.Value.Y + math.rad(90),Oval.Value.Z)
		print("ROTATED")
	end
end)

UIS.InputBegan:Connect(function(input, gpe)
	if UIS:IsKeyDown(Enum.KeyCode.T) then
		local Oval = game.Workspace.Ignore:WaitForChild("SelectBox").OrientationVal
		Oval.Value = Vector3.new(Oval.Value.X + math.rad(90), Oval.Value.Y,Oval.Value.Z)
		print("ROTATED")
	end
end)

UIS.InputBegan:Connect(function(input, gpe)
	if UIS:IsKeyDown(Enum.KeyCode.Y) then
		local Oval = game.Workspace.Ignore:WaitForChild("SelectBox").OrientationVal
		Oval.Value = Vector3.new(Oval.Value.X , Oval.Value.Y,Oval.Value.Z + math.rad(90))
		print("ROTATED")
	end
end)

My problem is that the rotation values given by the script are relative to the part, how can i prevent that?

Hmm. Why exactly do you need three events? can’t you just use elsif?

Also what exactly do you mean by

Do you want the natural orientation to the workspace?

Could you provide a picture of what is happening and what you would want to happen if thats alright?

1 Like

Yes I can, I just found this easier.
yes

As you can see, when i press t once to rotate in the X axis, it shows that it is pinning in its relative Y axis

Well I see. I am still not entirely sure what exactly your problem is however I could suggest a few changes that you could try and use to get a different outcome.

One might be to use CFrame:ToWorldSpace(CFrame.Angles(0,0,0)) for a rotation that is relative to itself.

You also have to realize that CFrames are not comutative that is A* B does not mean B * A.

One thing you could try is to use the constructor CFrame.fromMatrix() CFrames | Roblox Creator Documentation for more info.

I understand that you are not using CFrame however I believe that you really should as it is more powerful than the standard orientation and you can choose whether you rotate in object space or in world space.

Hopefully this helps :+1: