function onClick()
if box.Text == "TEST" then
box.Text = "Code accepted"
wait(2)
box.Text = "Enter Code"
else
box.Text = "Invalid code"
wait(2)
box.Text = "Enter Code"
end
end
script.Parent.MouseButton1Down:connect(onClick)
local plr = game.Players.LocalPlayer
local box = script.Parent.Parent.Enter
it doesnt work when i type code it doesnt change the word please help

2 comments
Sir may you explain how you are using the variable box before it has been defined?
wait so the variable needs to go to the top of the code