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

i am trying to make a code system but if i put the code in the text does not show? (GUI)

so i am trying to make a code system a very basic one but why does my code not work? if i put the code in the right text wont show

code = {'2020',
	'test',
	'cool',
	'maybe'}




for i,v in pairs(code) do
	if script.Parent.Text == v then
		script.Parent.Text = "Valid Command"
	else
		script.Parent.Text = "Not A Valid Command"		
		
	end
end

2 comments

0

What's the problem exactly?

0

the text wont show if i put the code in

1 answer

✓ Accepted answer

You just forgot to stop the loop, or it will replace the massage almost instantly:

You also forgot to make the code only run if you type the code, or if you click a button. As I don't have your UI, I just made it detect if the text changed, and detect based on that(not recommended, makes easy to guess codes)

code = {'2020',
    'test',
    'cool',
    'maybe'}



script.Parent.Changed:Connect(function()
for i,v in pairs(code) do
    if script.Parent.Text == v then
        script.Parent.Text = "Valid Command"
       break -- if you don't break the code, it will be replaced almost instaltly
    else
        script.Parent.Text = "Not A Valid Command"      
        --Don't break here, or it will not detect if its a valid message and its not the first on the list
    end
end
end)

4 comments

0

Thankyou @Leamir

0

You're welcome

0

but i want it to say Valid Command when pressed enter with your code when you say 202 and when you press the last 0 it just says Valid Command

0

but thankyou

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