Cant verify if a player is already in a table

By touching a part the player is supposed to be inserted into the table once but the script cant verify if the player has already been inserted

printing table.find(RedTeamPlayersTable, Player.Name) gives me “nil” in the output

local RedPart = game.Workspace.RedPart
local RedTeamPlayersTable = {}

RedPart.Touched:Connect(function(Hit)
	
	local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
	
	if table.find(RedTeamPlayersTable, Player.Name) then
		
		print("a")
		
		else
	
	table.insert(RedTeamPlayersTable, Player)
		
	end
end)
2 Likes

You’re inserting the Player Instance not the name and in the statement you’re looking for the name you should do this instead

table.insert(RedTeamPlayersTable, Player.Name)
2 Likes

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