Secret codes in gui

ok so picture you open up a gui, you go through it, you stumble upon something telling you to input a 4 letter code, you type in the code you found earlier and a secret door opens behind you, how would you do this.

TLDR: how to make a secret code inputter in a gui. basically like those secret codes to get rewards in clicker games

What you would do is create a text box and put a local script with this:

local box = script.Parent
local text = box.Text
repeat task.wait(.1) until text ~= " "
    if text = "--secret code" then
        --code to make door open
    end
end

The simple solution is just an if statement that checks if TextLabel.Text is equal to the secret code before running the related code. However if you want your script to be exploit-proof you must use a RemoteFunction and send the user typed code when they press the “Send” button and check if it is correct and provide the rewards on the server side, the code on the client should only show the client effects and such and not have the secret code hardcoded into it. Also you must add a rate limit to that RemoteFunction and if a client manually bypasses it(with an executor for example) you must kick them. Else they can just bruteforce the answer if they like.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.