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
Your problem was you were using a variable that wasn't even defined in your function. Code is read from top to bottom Next time, just make sure you include your variables before a function. My code below fixes this.
If this works make sure to mark my response as "Answered"
local plr = game.Players.LocalPlayer local box = script.Parent.Parent.Enter --I hope this is a TextBox script.Parent.MouseButton1Down:connect(function() if box.Test == "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