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

Table Printing is Repeating?

local players = game:GetService("Players")
function emptyfunc()		
end

script.Parent.Touched:Connect(function(hit)
	emptyfunc()
end)


local playersbyteam = {}

while true do
local touch = script.Parent:GetTouchingParts()
	for i,v in pairs(touch) do
		print(i, ":", v)
			wait(0.5)
local player = players:GetPlayerFromCharacter(v.Parent)
if player then
    if playersbyteam[player.Name]==nil then
	print("Player", player.Name)
	table.insert(playersbyteam,player.Name)
	print("PLAYERS TABLE:")print(unpack(playersbyteam)) 
elseif playersbyteam[player.Name]==true then
	return	
end
else
    print("Not a player")

end
	end
end

That is where my code is currently. Everything works fine until we get to printing out our table. I asked the code not to print it out if player's name is already in the table, but it still does it anyways. The problem I am trying to overcome here is the the player's name being printed out every 0.5 seconds to no extent or until they walk off;

1 answer

You have the printing in while true do FIRST without checking if it has been printed already, just swap the order.

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