Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Twitter code GUI wont work. The words don't change like they should. Can anyone help?

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

1

Sir may you explain how you are using the variable box before it has been defined?

0

wait so the variable needs to go to the top of the code

1 answer

✓ Accepted answer

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

1 comment

0

perfect thank you

This discussion is preserved as it was. New answers, comments, and votes are closed.