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

When i enter the correct code, it says its wrong. How do i fix it?

Asked by 1 year ago
Edited 1 year ago
-- locals
local text=script.Parent.input
local buttons=text.Parent.buttons

-- setup
local r=math.random(1,5)
if r==1 then code=2928 end if r==2 then code=9742 end if r==3 then code=2437 end if r==4 then code=5975 end if r==5 then code=4443 end
local input_code=""
text.Text=input_code
workspace["gameSetup_(v1)"].game.required.paper.text.text.Text="Uh, hey, Jack! U always forget the passcode for the door, the code is: "..code

-- handler
for i,button in pairs(buttons:GetChildren()) do
    button.MouseButton1Click:Connect(function()
        if tonumber(button.Name) and text.Parent.Parent.BrickColor==BrickColor.new("Steel blue") then
            input_code=input_code..button.Name
            text.Text=input_code
            text.Parent.Parent.beep:Play()
        end
    end)
end
print(code)
while wait(0.05) do
    if #text.Text>=4 then
        if input_code==code then
            text.Parent.Parent.BrickColor=BrickColor.new("Shamrock")
            text.Parent.Parent.correct:Play()
            wait(0.5)
            text.Parent.Parent.granted:Play()
            wait(9999) -- dont pay attention
        elseif input_code~=code then
        text.Parent.Parent.BrickColor=BrickColor.new("Persimmon")
        text.Text="Incorrect!"
        text.Parent.Parent.incorrect:Play()
        wait(2)
        text.Text=""
        input_code=""
        text.Parent.Parent.BrickColor=BrickColor.new("Steel blue") 
        end
    end
end

Answer this question