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

Why does this script crash my game?

Asked by 8 years ago

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?

1
maybe put a wait in the repeat loop, or use >= on the transparency for the until theCJarmy7 1293 — 8y
0
^ Thanks. The wait worked. I don't know why, I always forget to add wait() to repeat functions.. TheHospitalDev 1134 — 8y

1 answer

Log in to vote
-3
Answered by 8 years ago

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

Ad

Answer this question