Code script not working

So I was making a game and I decided to make a code GUI so I made the GUI and everything and then at the end my script didnt work I tried and tried I did it in a function so I dont know if that would effect it but yeah so here is my script:

local plr = game.Players.LocalPlayer
local codesbox = script.Parent.Parent.TextBox

local function codesCheck()
if codesbox.Text == “RELEASE” then
plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + 1000
codesbox.Text = “Code Redeem!”
wait(1)
codesbox.Text = “Type Code Here”
elseif
codesbox.Text == “HAPPY2021” then
plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + 500
codesbox.Text = “Code Redeem!”
wait(1)
codesbox.Text = “Type Code Here”
else
codesbox.Text = “Code is invalid please try again”
wait(1)
codesbox.Text = “Type Code Here”
end
end

codesCheck()

the code is inside a redeem GUI it doesnt even say anything in the output so I dont know whats wrong.

You are just firing the function at the end of the script. The player has not typed in “RELEASE” yet.

Do this instead:

codesbox.FocusLost:Connect(codesCheck)

Ok but where would I put it or what would I replace it with?

local plr = game.Players.LocalPlayer
local codesbox = script.Parent.Parent.TextBox

local function codesCheck()
    if codesbox.Text == "RELEASE" then
        plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + 1000
        codesbox.Text = "Code Redeem!"
        wait(1)
        codesbox.Text = "Type Code Here"
    elseif codesbox.Text == "HAPPY2021" then
        plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + 500
        codesbox.Text = "Code Redeem!"
        wait(1)
        codesbox.Text = "Type Code Here"
    else
        codesbox.Text = "Code is invalid please try again"
        wait(1)
        codesbox.Text = "Type Code Here"
    end
end

codesbox.FocusLost:Connect(codesCheck)

EDIT: Give the solution to @IAmPinleon as he practically gave you the answer.

Ok thank you I will try this I hope it works thankyou have a nice day!

It worked but I gave the solution to him like you said

It worked thank you for the help and hope you have a nice day!