#PROBLEM

So, a few days ago i felt like improvising a twitter redeem code; but for some reason it's skipping this If statement.

#CODE;

local TwitterCodes = {
	["hi"] = 20,
	["no"] = 50,
	
}

function check()
	for i, v in pairs(TwitterCodes) do
		if script.Parent.TextBox.Text == i then
			print("You gained " .. v .. " Cash!")
		else
			print(script.Parent.TextBox.Text, " Is not a valid code")
			
		end
	end
end

local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(input, gameprocessed)
	
	if gameprocessed then return end
	
	if input.KeyCode == Enum.KeyCode.A then
		check()
	end
end)

			

7 comments

0

_

0

Hello, you mean the first if?

0

You would check if the text is equal to v. "i" contains the number of times you have went through that loop, v contains the value you are looking for.

0

uhhh what???

0

Can you please write an answer explaining?

0

i is the index v is the value/object. i represents the placement number of the object/value is inside of the holding parent. v is the value/object that has those properties. i is just the number. Change line 9 to if script.Parent.TextBox.Text == v then

0

Doesn't work, the twitter codes are; Yes, no, and they have a value; (the amount of coins i want to give them), what i wanted is an answer.