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

Why does this script crash my game?

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

1

maybe put a wait in the repeat loop, or use >= on the transparency for the until

0

^ Thanks. The wait worked. I don't know why, I always forget to add wait() to repeat functions..

1 answer

well i am not a coding genius infact i am really bad at coding but have you tried putting waits if the game is acting on too many codes at once your game might crash that is my answer other people may have better ones hope i helped

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