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

How to get all the s?ame table index

local Table = {Sao = 'S',Sao = 'U',Sao = 'C',Sao = 'K',Sao = 'S'}

for i,v in pairs(Table) do
	print(i)
end

--Only Prints Sao Once I want it to print 5 times

--[[  --]]

--What Im triyng to do
	


local Table = {Sao = 'S',Sao = 'U',Sao = 'C',Sao = 'K',Sao = 'S'}

local AmountOfSao = 0

for i,v in pairs(Table) do
	if i == 'Sao' then
		AmountOfSao = AmountOfSao + 1
	end
end


print(AmountOfSao) -- Should print 5


Basically I want to add all the index up and print a number how how many same indexes there are

AmountOfSao should print 5

1 comment

0

Sao is all the same. Like I think all this does is change what Sao in the table so there is only one (I think). So like you need to have everything different.

1 answer

Table indexes are unique; you cannot have duplicate/same indexes in a table Use an array or change each index in your Table

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