Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
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

1
Sir may you explain how you are using the variable box before it has been defined? farrizbb 465 — 6y
0
wait so the variable needs to go to the top of the code EpicAshtonTheBoy 33 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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
0
perfect thank you EpicAshtonTheBoy 33 — 6y
Ad

Answer this question