Jump to content

Moving my GUI


Recommended Posts

Hello guys, im trying to make a moving GUI, with onClientRender, but I have one prob. It moves to slow if I do the Y + 1, but that is the only one that will work. How can i make it so I can do something like Y + 10, and it will stop in the center?

Code:

bindKey("M","down", 
    function () 
        addEventHandler("onClientRender", root, moveGUI) 
    end 
) 
  
function moveGUI() 
    local x, y = guiGetPosition(window, false) 
    if (y ~= (ry/2-334/2)) then -- If its not the center 
        guiSetPosition(window, x, y + 1, false) -- Too slow  
    else 
        removeEventHandler("onClientRender", root, moveGUI) 
    end 
end 

Link to comment
Guest Guest4401
bindKey("M","down", 
    function () 
        addEventHandler("onClientRender", root, moveGUI) 
    end 
) 
  
function moveGUI() 
    local x, y = guiGetPosition(window, false) 
    if (y+10) < (ry/2-334/2) then 
        guiSetPosition(window, x, y + 10, false) 
    else 
        guiSetPosition(window, x, ry/2-334/2, false) 
        removeEventHandler("onClientRender", root, moveGUI) 
    end 
end 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...