How to rotate a UI the same way as a Part

So I’m making this arcade thing for a game. So for the UI’s to have more properties or events, I made a replica with normal 3D parts and then copy the parts properties to equivalent UI’s in the arcade. The problem is that when I try to rotate a Part, the UI’s don’t rotate the same way and I don’t know why. The UI’s rotate 180° and then return (like an oscillation), but the parts rotate as I want (just one direction and 360°). Here’s a video of what’s happening. (The right side is the part and the left side the UI.) As you can see, even in the properties the value of rotation don’t stay equal.

Any other property such as size, position, colour, etc. is working fine this way.

Can someone help? (The UI’s are on a SurfaceGUI)

Video: https://photos.app.goo.gl/kRxHYECEiHy59Zam6

This is the script I’m using. (this is in the UI with a normal script)

workspace.Part.Changed:Connect(function (property)
	if property == "Rotation" then
		local xd = workspace.Rocket.Rotation.Y
		script.Parent.Rotation = xd
	end
end)

Thank you, I’ll answer any questions you may have.

2 Likes

You want the UI to rotate as well as the part, am I understanding you correctly?

1 Like

Yeah that’s right. What I need is the UI to rotate 360° without the revertion (like the part does)

What do you mean by revertion?

You might need to make the rotation positive.

Code:

workspace.Part:GetPropertyChangedSignal("Rotation"):Connect(function()
	local xd = workspace.Rocket.Rotation.Y
	script.Parent.Rotation = math.abs(xd)
end)

math.abs makes the integer positive.

1 Like

The UI spins 180° degrees and then rotates another 180° but in the opposite direction. It’s like it is oscillating, and i just want it to rotate normally.

Axes in 3 space can change abruptly from positive to negative. This may be the case, try using math.abs()

Okay I tried but now the UI just oscillates 90°.

Try sizing your part differently, so that the orientation is facing a different direction. Your original code should work, it’s just that the two objects have different starting orientations so it looks off.

I figure it out. Instead of using Rocket.Rotation, I needed to use Rocket.Orientation. I also needed to make the xd negative because it was spining to the opposite side, but now it works. Thank you!

1 Like

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