I'm trying to make an "Attempts" script, where you only have 5 attempts, but the script won't subtract the value.
local UName = script.Parent:WaitForChild("UName") ------------------------------------- local UPass = script.Parent:WaitForChild("UPass") ------------------------------------- local Attempts = script.Parent:WaitForChild("Attempts").Value ------------------------------------- local Button = script.Parent:WaitForChild("Login") ------------------------------------- local pass = { ["Herro"] = true; } ------------------------------------- local transparency = 0 ------------------------------------- local debounce = false ------------------------------------- local countdown = 10 ------------------------------------- local warning = "You have "..Attempts.." attempts left." ---------------------- local function checkAttempts() if Attempts == 0 then --Randomness else Attempts = Attempts - 1 --Here script.Parent.Warning.Text = warning wait(3) script.Parent.Warning.Text = "" debounce = false end end ------------------------------------- Button.MouseButton1Click:connect(function() if debounce == false then debounce = true if pass[UPass.Text] then --Randomness else checkAttempts() end end end)
It will display the text, just not subtract the value. Any suggestions, because there aren't any errors.
Info:
--No filtering Enabled --It's a local script.
Its a simple yet common mistake, on line 05, all you need to do is take away the ".Value" part and re-assign this to where you next use the variable. This is because when you assigned the variable you also assigned the value which means that you cant change it, where as now you can access the child of it:
--(All errors should be fixed) 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 countdown = 10 ------------------------------------- local warning = "You have "..Attempts.Value.." attempts left." ---------------------- local function checkAttempts() if Attempts.Value == 0 then --Randomness else Attempts.Value = Attempts.Value - 1 script.Parent.Warning.Text = warning wait(3) script.Parent.Warning.Text = "" debounce = false end end ------------------------------------- Button.MouseButton1Click:connect(function() if debounce == false then debounce = true if pass[UPass.Text] then --Randomness else checkAttempts() end end end)