I need help with Code System

Hello! I want made Code system that check if TextBox.Text is some value from list, but this dousn’t work :sob: This is my Script:

local Codes = {
	["underthewater"] = 50,
	["CONSOLE"] = 343,
	["Jarro"] = 300,
	["alpha"] = 1000,
	["devs"] = 2000
}



local Box = script.Parent.MainHandlerCode.TextBox
local code = Box.Text
local btn = script.Parent.MainHandlerCode.TextButton
local Value = game.Workspace.Values.Credits -- I used this for example :D
btn.MouseButton1Up:Connect(function(player)
	if Box.Text == (Codes[code]) then
		Value.Value = Value.Value + code
	end
end)

What’s wrong is with this script?

Have a great day :grinning:

Should be

if Codes[Box.Text] then

And change

Value.Value = Value.Value + code

To

Value.Value += Codes[Box.Text]

And if in the future you plan on making this system work for players leaderboard stats, this has to work from the server as well so RemoteEvent

2 Likes

Thanks for help!!! :grinning:

Have a great day!

1 Like

If you wanna load the code use loadstring(code)() make usre serverscriptservice loadstringenable is on but can affect the game to be more vunerable to exploits

I don’t using Server Script, I using Local Script because it’s a GUI, but thanks for tip :grin:

1 Like