Comparing 1 IntValue to a Table

Just as the titles says. I’m trying to compare an IntValue to a whole Table.
Here is my current script:

local Numbers = {1,2,3,4,5}
local IntValue = script.IntValue --(this value is 1 btw)
if IntValue.Value == Numbers then
	print("Success")
end

But it’s not printing out “Success”. What am I doing wrong?

1 Like

If you use it like your example then do Number[1]

local Numbers = {1,2,3,4,5}
local IntValue = script.IntValue --(this value is 1 btw)
if IntValue.Value == Numbers[1] then
	print("Success")
end

Else you would do

local Numbers = {1,2,3,4,5}
local IntValue = script.IntValue --(this value is 1 btw)
for i, v in Numbers do
	if IntValue.Value == v then
		print("Success")
	end
end
local Numbers = {1,2,3,4,5}
local IntValue = script.IntValue --(this value is 1 btw)
if IntValue.Value == Numbers[IntValue.Value] then
	print("Success")
end

I tried the first example you showed but it’s still not printing out “Success”.

Are you sure that the IntValue is 1?

Try

local Numbers = {1, 2, 3, 4, 5}
local IntValue = script.IntValue-- Assuming this value is 1

if table.find(Numbers, IntValue.Value) then
	print("Success")
end

1 Like

The script I wrote was just a simplified version. I’m making an aura system and I’m trying to check if you already have the current aura that is being showed on screen or not.
This is the problem right now:

print(AuraNumber.Value.."=",BoughtAuras[AuraNumber.Value]) --"1 = 1"
if AuraNumber.Value == BoughtAuras[AuraNumber.Value] then
	print("Success") --doesn't print out
end

Why doesn’t “Success” get printed out if 1 = 1?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.