Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I use :wait() to wait until a ScreenGui's position is whatever?

Asked by 8 years ago

The title really says it all.

I'm building an AdminGui, I'm just adding the 10%. I want an ImageButton to rotate, and it does, but while the GUI is being tweened, you can click the button, rotate it, and cause the GUI to break temporarily. I have a debounce in place, but it's not effective because it deactivates immediately after clicking. So, I need it to deactivate the debounce after the GUI has been tweened.

So, "How would I use :wait() to wait until a ScreenGui's position is whatever?".

1 answer

Log in to vote
1
Answered by
drahsid5 250 Moderation Voter
8 years ago

It's a simple do while function that takes rotate into account:

rotate = false --Debounce
function waitUntil(ed,gui) --Create a function for waiting until a GUI is in the right spot
    if rotate == false then --If rotating is false
        repeat wait() gui.Rotation = 0 rotate = false until gui.Position == ed --force it to not rotate until the movement is finished
        return true --return true
    else 
        repeat wait() until rotate == false --if rotate is true wait until rotate is false
        waitUntil(end,gui) --call the function
        return --return nil
    end
end

function rotate(gui) --Create a function for rotating
    rotate = true --set rotate to true
    for i=1,90 do -- or how many degrees you want to rotate it
        if rotate == false then break end --if the tween started stop
        gui.Rotation = gui.Rotation+1 --rotate
        game:GetService("RunService").RenderStepped:wait() --wait one frame
    end
    rotate = false --set rotate to false
end
0
I got it fixed, but not with what you gave me; I didn't understand it, and I don't want to use something I don't understand. What I did was wait 2.5 seconds, which is the amount of time the GUI is given to tween itself, and it works seamlessly. But, I do that you very much for replying and trying to help me. MINEBLOX106 55 — 8y
0
You didn't even call the functions... Validark 1580 — 8y
0
Narrev, You don't call the functions in example code. It's not going to run anyways. drahsid5 250 — 8y
Ad

Answer this question