How to make a GUI that goes in the direction that is rotated

I need help to how to make many images (like 20) to go to all difrend directions that the image has randomly set to a random Rotation and the goes forwards for like 0.5 seconds.

I had tried that before but i didnt know to move it acordingly to the Rotation.

Thats a drawing on how the image should move forward based on its Rotation


(Sorry for my bad Drawing)

How can i achieve this?
Any help whould be greatly appreciated!!!

Is this a screen gui, or a Part in the Workspace?
If you need them moving away from a Part just put a ParticleEmitter in the Part and change the image to the one you want.

You can get the 2D vector of the direction of a rotation by using the formula:

local direction = Vector2.new(math.cos(rotation), math.sin(rotation)

Then you can move the gui in the direction by doing:

local speed = 5 -- Pixels per frame

game:GetService("RunService").RenderStepped:Connect(function()
    local direction = Vector2.new(math.cos(gui.Rotation), math.sin(gui.Rotation)
    gui.Position = UDim2.fromOffset( -- Offsets the gui
        gui.AbsolutePosition.X + direction.X * speed
        gui.AbsolutePosition.Y + direction.Y * speed
    )
end)
2 Likes