I've made a login gui (No, not one of those. For a beta game) and when I test it, it crashed, but I don't know why.
local UName = script.Parent:WaitForChild("UName")
local UPass = script.Parent:WaitForChild("UPass")
local Attempts = script.Parent:WaitForChild("Attempts")
local Button = script.Parent:WaitForChild("Login")
local pass = {["Herro"] = true;}
local transparency = 0
local debounce = false
local warningA = "You have "
local warningB = " attempts left."
local countdown = 10
local function checkAttempts()
if Attempts.Value == 0 then
script.Parent.Warning.Text = "You will be kicked in "..countdown.. " seconds."
repeat
countdown = countdown - 1
wait(1)
until countdown == 0
game.Players.LocalPlayer:Kick()
else
Attempts.Value = Attempts.Value - 1
script.Parent.Warning.Text = warningA..Attempts.Value..warningB
wait(6)
script.Parent.Warning.Text = ""
debounce = false
end
end
UName.Text = game.Players.LocalPlayer.Name
Button.MouseButton1Click:connect(function()
if debounce == false then
debounce = true
if pass[UPass.Text] then
repeat
script.Parent.Parent.Parent.Parent.BackgroundTransparency = script.Parent.Parent.Parent.Parent.BackgroundTransparency + 0.05
script.Parent.Parent.Parent.Parent.Frame.BackgroundTransparency = script.Parent.Parent.Parent.Parent.Frame.BackgroundTransparency + 0.05
script.Parent.Parent.Parent.Parent.Frame.LittleRedBar.BackgroundTransparency = script.Parent.Parent.Parent.Parent.Frame.LittleRedBar.BackgroundTransparency + 0.05
script.Parent.Parent.Parent.Parent.Frame.Frame.BackgroundTransparency = script.Parent.Parent.Parent.Parent.Frame.BackgroundTransparency + 0.05
transparency = transparency + 0.05
until transparency == 1
else
checkAttempts()
end
end
end)
If possible, how would I also make it more efficient?

2 comments
maybe put a wait in the repeat loop, or use >= on the transparency for the until
^ Thanks. The wait worked. I don't know why, I always forget to add wait() to repeat functions..