Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

You should use TweenPostion() instead of repeat until

This discussion is preserved as it was. New answers, comments, and votes are closed.