Move image based on rotation

Hello!

How can you move a GUI based on its rotation? for example, move a GUI in the same direction of the rotation.

Thanks!

Hello, I don’t quite understand what do you mean by moving a GUI in the same direction of the rotation. Could you provide an example?

Basically, he wants to move a GUI to the faces of it. For example, orientation is 45 degrees, then what would happen is that the gui would move towards the corner. (At least if it’s in the middle of the screen.)

Oh, so it wants it to move locally? If that’s the case, I don’t know about this. I know CFram:ToWorldSpace() can do this.

He’s asking about a UI, CFrame:ToWorldSpace() would not work in this instance as UIs use UDim2

What they would want to do is probably use triangle trig in order to determine the movement
image

1 Like

Thanks for this! I’ll use this!

Sorry for crazy old bump but how would you write it out in script?

You have to use vectors.
local image = Instance.new(“ImageLabel”, script.Parent)
local vec = CFrame.Angles(0, 0, math.rad(45)).lookVector

image.Position = UDim2.new(0.5, 0, 0.5, 0)

script.Parent.Changed:connect(function()
image.Position = image.Position + vec
end)

This code moves the image down-right by the vector.
Note: script.Parent can be anything that can be changed.