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

Why does the script keep repeating even after the GUI arrived where it needs to be?

Asked by
Prioxis 673 Moderation Voter
10 years ago

so I made a GUI that when you toggle it, it'll slide into the players View for some odd reason though it keeps sliding and never stops

there's no errors in the output and I use the same script for a different GUI and that one works fine

the other GUI did this until I added in a debounce thats what the Moving variable is

Here's the script :

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Frame = script.Parent.Main
local Moving = false


function Open()
    if not Moving then
    Moving = true
    print'opening'
    Frame.Visible = true
    script.Parent.Label.Visible = false
    repeat
        wait(0.05)
        Frame.Position = Frame.Position +UDim2.new(0.02, 0, 0, 0)

    until 
    Frame.Position == UDim2.new(0.1, 0, 0.35, 0)
    Moving = false
    wait(3)
    end
end

function Close()
    if not Moving then
        Moving = true
    print'Closing'
    script.Parent.Label.Visible = true
    repeat
        wait(0.05)
    Frame.Position = Frame.Position -UDim2.new(0.02, 0, 0, 0)
    until 
    Frame.Position == UDim2.new(-0.4, 0, 0.35, 0)
Frame.Visible = false
Moving = false
wait(3)
    end
end

Mouse.KeyDown:connect(function(key)
if key == "g" then
if script.Parent.Main.Visible == true then
    Close()
else
    Open()
end
end
end)

1 answer

Log in to vote
0
Answered by 10 years ago

You should use TweenPostion() instead of repeat until

Ad

Answer this question