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

Syntax Questing and Tables?

How would I find if a string matches a value in a table, while also seeing what tuple it is? (I believe that's the correct term. What I mean is it's 'sequence' in the table, I guess.)

Why I ask this? I'm working on a little code redemption GUI, and I need a value to be removed from a table when the player redeems a value in the table, so they can't redeem it again and again and again.

1 comment

0

This isn't very constructive, could you try to atleast try and script it. Post your script here and I will help you.

1 answer

✓ Accepted answer

I think the term you're looking for is 'index'. A tuple is a variable-number of, well, variables. Typically upvalues for functions.

To actually answer your question, use a for loop:

local playerCodes = {'124525', 'bonanza', '125astdg'}
local textEntered = '124525'
for index, value in ipairs(playerCodes) do
	if value == textEntered then
		redeem(value) --Or however you handling redeeming a specific code.
		table.remove(playerCodes, index)
	end
end

There are some problems that might arise by using this method, but they're all edge case and if you don't know how to do this to begin with, I doubt you'd write code that would cause those bugs.

In any case, if you have bugged code, definitely ask about it here.

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