How do you move a gui that takes in account of rotation?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to move a frame like the way you would move a part with CFrame.
    If I moved it up, and the rotation was 45 degrees, that would be taken in account and would be moved up at a diagonal.

  2. What is the issue? Include screenshots / videos if possible!
    I don’t know how to do this. Math’s is not my strong point and I’ve looked in a lot of places for answers.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried to set the positions manually, but then realized that would take a long time and it wasn’t worth it. I was thinking of making invisible parts and cframing them. Using @orange451 's WorldToSurfaceGui module, I could position the Frame to the part Position. This might work, but it would be messy and i want my game to be fully GUI.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Any help is appreciated!

This code should work if your frame uses offset, if you’re using scale then you may want to play around with it a bit. The newY value is the Y offset that the frame will travel to.

local frame = script.Parent.Frame

local function tween(newY)
    frame:TweenPosition(,frame.Position.X.Offset + math.tan(math.rad(frame.Rotation))*(frame.Position.Y.Offset-newY),0,newY))


Thank you! And yes, it does use offset!

1 Like