Trying to add gravity to a frame

Hello !
I am trying to add gravity to a frame but, i don’t know how to make that.

So i am just trying to do something like this but with frame (gui):

So i want to know if it’s possible to add gravity to a frame or make a frame that go down but then the frame stop falling when it touch another frame

I don’t found any good script to make what i want to do then uhh… this is why i ask help.
I found something like that but this is not what i want because there is no gravity/falling effect:

function collidesWith(gui1, gui2)
    local gui1_topLeft = gui1.AbsolutePosition
    local gui1_bottomRight = gui1_topLeft + gui1.AbsoluteSize

    local gui2_topLeft = gui2.AbsolutePosition
    local gui2_bottomRight = gui2_topLeft + gui2.AbsoluteSize

    return ((gui1_topLeft.x < gui2_bottomRight.x and gui1_bottomRight.x > gui2_topLeft.x) and (gui1_topLeft.y < gui2_bottomRight.y and gui1_bottomRight.y > gui2_topLeft.y)) 
end

I hope it’s possible to add gravity or make a falling effect with collisions
Have a good day !

You can do a while true do loop until the frame collides with another GUI.

I have seen many problems with 2D collision and these topics should help you with detecting when the GUI hits another frame.

1 Like

Ik but While True Do = laggy game
and it’s isn’t smooth

1 Like

You can add a wait to while true do.
I would recommend doing while wait(0.01) do to help reduce lag.

or then, if i want to make a “jump ability to the gui” then i can add a debounce, and a jump animation

Yes, you can do both of those things. You can use CFrame to do the jump animation.