Can you use lists as a parameter in a function?

Say I had a list:

players = {player1, player2, player3}

callingModuleScript(players)

Would this pass the players list into the module script? Or does this not work as I’m having issues as it only seems to detect player3 from the list when I try access it from the module script

Yes, you can pass tables through ModuleScripts, if you’re getting errors It’s because of your script.

Please share more details so we can help you

1 Like

Ah yes thank you I have realised its something to do with the actual list. I’m finding its putting the same player in twice so instead of {player1, player2}, im getting {player2, player2}.

Here is where I define the list:

table.clear(winners)
			table.clear(losers)
			
			if team1Wins == 5 then
				if T1Player1 then
					tempT1Player1 = T1Player1
					table.insert(winners, tempT1Player1)
				end
				if T1Player2 then
					tempT1Player2 = T1Player2
					table.insert(winners, tempT1Player1)
				end
				if T1Player3 then
					tempT1Player3 = T1Player3
					table.insert(winners, tempT1Player1)
				end
				if T2Player1 then
					tempT2Player1 = T2Player1
					table.insert(losers, tempT2Player1)
				end
				if T2Player2 then
					tempT2Player2 = T2Player2
					table.insert(losers, tempT2Player2)
				end
				if T2Player3 then
					tempT2Player3 = T2Player3
					table.insert(losers, tempT2Player3)
				end
			elseif team2Wins == 5 then
				if T1Player1 then
					tempT1Player1 = T1Player1
					table.insert(losers, tempT1Player1)
				end
				if T1Player2 then
					tempT1Player2 = T1Player2
					table.insert(losers, tempT1Player1)
				end
				if T1Player3 then
					tempT1Player3 = T1Player3
					table.insert(losers, tempT1Player1)
				end
				if T2Player1 then
					tempT2Player1 = T2Player1
					table.insert(winners, tempT2Player1)
				end
				if T2Player2 then
					tempT2Player2 = T2Player2
					table.insert(winners, tempT2Player2)
				end
				if T2Player3 then
					tempT2Player3 = T2Player3
					table.insert(winners, tempT2Player3)
				end
			end

All of the T1Player1 etc are just variables for the player. I don’t think this is the issue as these variables all work fine

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