How do I put a table in a message?

What I mean by list is that I want a message in the workspace to be “Player1, Player2 has survived.”. I tried so much and nothing worked. Even tried uncopylocked games, but nothing worked. No solutions anywhere. I need help asap.

local alivecount = 0
local clock = 20
local playerlist = {}

game.Players.PlayerAdded:Connect(function(plr)
	local alive = Instance.new("BoolValue",plr)
	alive.Name = "AliveBool"
	local leaderstats = Instance.new("Folder",plr)
	leaderstats.Name = "leaderstats"
	local points = Instance.new("NumberValue",leaderstats)
	points.Value = 0
	points.Name = "Points"
	
end)


function map()
	clock = 20
	for i = 1,clock do
		clock = clock -1
		workspace.Message.Text = clock .. " seconds til next game."
		wait(1)
	end
	if clock == 0 then
		for i = 1,35 do
				workspace.tick:Play()
				wait(.15)
local mapsmsg = game.Lighting.Maps:GetChildren()
local mapmsg =  mapsmsg[math.random(1,#mapsmsg)]
				workspace.Message.Text = mapmsg.Name
		end
		
	
	local plr = game.Players:GetPlayers()
	for i = 1,#plr do
		alivecount = i
		print(alivecount)
	end
	        local maps = game.Lighting.Maps:GetChildren()
local choice =  maps[math.random(1,#maps)]
workspace.Message.Text = "The map that has been chosen is... " .. choice.Name .. "!"
workspace.bell:Play()
	workspace.Five:Play()
		wait(1)
		workspace.Four:Play()
		wait(1)
		workspace.Three:Play()
		wait(1)
		workspace.Two:Play()
		wait(1)
		workspace.One:Play()
		wait(1)
workspace.Message.Text = "BEGIN!"
workspace.freshmeat:Play()
for i,v in pairs(game.Players:GetChildren()) do
	table.insert(playerlist,v.Name)
		v.AliveBool.Value = true
		v.Character.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(37, 30, -83))
		table.insert(playerlist,v.Name)

	end
choice:Clone().Parent = workspace
wait(1)
workspace.Message.Text = "A game is in progress."


		for i,v in pairs(game.Players:GetPlayers()) do
			v.Character.Humanoid.Died:Connect(function()
				alivecount = alivecount -1
				v.AliveBool.Value = false
				table.remove(playerlist,v.Name)
					end)
			end
			workspace.sad:Play()
		wait(60)
		
		if alivecount >0 then
			workspace.cheer:Play()
			workspace[choice.Name]:Destroy()
			for i,v in pairs(game.Players:GetPlayers()) do
				if v.AliveBool.Value == true and alivecount >1 then
					workspace.sad:Stop()
					workspace.Message.Text = "Two or more people survived, congrats!"
					v.AliveBool.Value = false
					v.leaderstats.Points.Value = v.leaderstats.Points.Value +200
											table.remove(playerlist,v.Name)
				elseif v.AliveBool.Value == true and alivecount == 1 then
						workspace.Message.Text = "One person only survived - congrats."
					v.AliveBool.Value = false
					v.leaderstats.Points.Value = v.leaderstats.Points.Value +200
						workspace.sad:Stop()
						table.remove(playerlist,v.Name)
				end
			end
			wait(10)
			map()
		else
				workspace.evil:Play()
				workspace[choice.Name]:Destroy()
				workspace.Message.Text = "The bawlz killed everbody!"
				workspace.sad:Stop()
				wait(10)
				map()
				end
				end
			end
			map()
3 Likes

To elaborate, I want it like the one in R.U.N where if there is 2 players or more, it always has their name like this. “Player1, Player2 has survived” for example. How do I do this?

1 Like

I am sure there is a better solution to this than mine, but in my own personal experience a method along the lines of this has worked perfectly:

local RoundEndMessage = ""
for i,player in pairs(Alive_Player_Table) do
   if i == #Alive_Player_Table then
      RoundEndMessage = RoundEndMessage .. player.Name .. " "
   else
      RoundEndMessage = RoundEndMessage .. player.Name .. ", "
   end
end
RoundEndMessage = RoundEndMessage.."has survived"
1 Like

will try, thanks if it doesnt or does work.

1 Like

Your solution is good, but there is a more good one. it is called table.concat(Alive_Players_Table,", ")

so, very easy ur code will be transformed into this:

local RoundEndMessage = table.concat(Alive_Players_Table,",").." has survived"
2 Likes

table.concat() Will not put a “,” at the final.

3 Likes

I was truthfully unaware of this, it must’ve been errors in my previous code that led me astray in this belief.

3 Likes

Off topic, but I don’t even know how to use table.remove, to remove the player from the table lol. Ill try the concatenate thing that turtle said.

His post isn’t really of topic, and I don’t think it is really good to put things like “lol” or “lmao” in ur post.

1 Like

Sorry. didn’t mean to break rules or anything.

1 Like

Also, by off topic I meant it was me.

1 Like

Also, on your 1 line of code, on my script it said ’ [20:35:46.997 - Workspace.Game:83: bad argument #1 (table expected, got nil)])’

You need to put a table instead of Alive_Player_Table .

1 Like

Yeah, the table would have {"Player1,“Player2”} in it. It some reason said that twice.

Can you show me ur code? As I don’t think you really put a table.

1 Like

Ill show you.

local alivecount = 0
local clock = 20
local playerlist = {}
local RoundEndMessage = workspace.Message
game.Players.PlayerAdded:Connect(function(plr)
	local alive = Instance.new("BoolValue",plr)
	alive.Name = "AliveBool"
	local leaderstats = Instance.new("Folder",plr)
	leaderstats.Name = "leaderstats"
	local points = Instance.new("NumberValue",leaderstats)
	points.Value = 0
	points.Name = "Points"
	
end)


function map()
	clock = 0
	for i = 1,clock do
		clock = clock -1
		workspace.Message.Text = clock .. " seconds til next game."
		wait(1)
	end
	if clock == 0 then
		for i = 1,35 do
				workspace.tick:Play()
				wait(.15)
local mapsmsg = game.Lighting.Maps:GetChildren()
local mapmsg =  mapsmsg[math.random(1,#mapsmsg)]
				workspace.Message.Text = mapmsg.Name
		end
		
	
	local plr = game.Players:GetPlayers()
	for i = 1,#plr do
		alivecount = i
		print(alivecount)
	end
	        local maps = game.Lighting.Maps:GetChildren()
local choice =  maps[math.random(1,#maps)]
workspace.Message.Text = "The map that has been chosen is... " .. choice.Name .. "!"
workspace.bell:Play()
	workspace.Five:Play()
		wait(1)
		workspace.Four:Play()
		wait(1)
		workspace.Three:Play()
		wait(1)
		workspace.Two:Play()
		wait(1)
		workspace.One:Play()
		wait(1)
workspace.Message.Text = "BEGIN!"
workspace.freshmeat:Play()
for i,v in pairs(game.Players:GetChildren()) do
	table.insert(playerlist,v.Name)
		v.AliveBool.Value = true
		v.Character.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(37, 30, -83))
		table.insert(playerlist,v.Name)

	end
choice:Clone().Parent = workspace
wait(1)
workspace.Message.Text = "A game is in progress."


		for i,v in pairs(game.Players:GetPlayers()) do
			v.Character.Humanoid.Died:Connect(function()
				alivecount = alivecount -1
				v.AliveBool.Value = false
				table.remove(playerlist,v.Name[i])
					end)
			end
			workspace.sad:Play()
		wait(1)
		
		if alivecount >0 then
			workspace.cheer:Play()
			workspace[choice.Name]:Destroy()
			for i,v in pairs(game.Players:GetPlayers()) do
				if v.AliveBool.Value == true and alivecount >1 then
					workspace.sad:Stop()
					local RoundEndMessage = table.concat(playerlist,",").." has survived"
					workspace.Message.Text = RoundEndMessage
					v.AliveBool.Value = false
					v.leaderstats.Points.Value = v.leaderstats.Points.Value +200
											playerlist = nil
				elseif v.AliveBool.Value == true and alivecount == 1 then
						workspace.Message.Text = "One person only survived - congrats."
					v.AliveBool.Value = false
					v.leaderstats.Points.Value = v.leaderstats.Points.Value +200
						workspace.sad:Stop()
						playerlist = nil
				end
			end
			wait(10)
			map()
		else
				workspace.evil:Play()
				workspace[choice.Name]:Destroy()
				workspace.Message.Text = "The bawlz killed everbody!"
				workspace.sad:Stop()
				wait(10)
				map()
				playerlist = nil
				end
				end
			end
			map()

just letting you know, its really big

You do not know how to use table.remove()?

1 Like

Not even good at that infact- sorry for my dumb lua knowledge.

After checking ur script a minute, i saw you are setting playerlist to nil, I changed a bit ur code and i get this:

local alivecount = 0
local clock = 20
local playerlist = {}
local RoundEndMessage = workspace.Message
game.Players.PlayerAdded:Connect(function(plr)
	local alive = Instance.new("BoolValue",plr)
	alive.Name = "AliveBool"
	local leaderstats = Instance.new("Folder",plr)
	leaderstats.Name = "leaderstats"
	local points = Instance.new("NumberValue",leaderstats)
	points.Value = 0
	points.Name = "Points"
	
end)


function map()
	clock = 0
	for i = 1,clock do
		clock = clock -1
		workspace.Message.Text = clock .. " seconds til next game."
		wait(1)
	end
	if clock == 0 then
		for i = 1,35 do
				workspace.tick:Play()
				wait(.15)
local mapsmsg = game.Lighting.Maps:GetChildren()
local mapmsg =  mapsmsg[math.random(1,#mapsmsg)]
				workspace.Message.Text = mapmsg.Name
		end
		
	
	local plr = game.Players:GetPlayers()
	for i = 1,#plr do
		alivecount = i
		print(alivecount)
	end
	        local maps = game.Lighting.Maps:GetChildren()
local choice =  maps[math.random(1,#maps)]
workspace.Message.Text = "The map that has been chosen is... " .. choice.Name .. "!"
workspace.bell:Play()
	workspace.Five:Play()
		wait(1)
		workspace.Four:Play()
		wait(1)
		workspace.Three:Play()
		wait(1)
		workspace.Two:Play()
		wait(1)
		workspace.One:Play()
		wait(1)
workspace.Message.Text = "BEGIN!"
workspace.freshmeat:Play()
for i,v in pairs(game.Players:GetChildren()) do
	table.insert(playerlist,v.Name)
		v.AliveBool.Value = true
		v.Character.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(37, 30, -83))
		table.insert(playerlist,v.Name)

	end
choice:Clone().Parent = workspace
wait(1)
workspace.Message.Text = "A game is in progress."


		for i,v in pairs(game.Players:GetPlayers()) do
			v.Character.Humanoid.Died:Connect(function()
				alivecount = alivecount -1
				v.AliveBool.Value = false
				table.remove(playerlist,v.Name[i])
					end)
			end
			workspace.sad:Play()
		wait(1)
		
		if alivecount >0 then
			workspace.cheer:Play()
			workspace[choice.Name]:Destroy()
			for i,v in pairs(game.Players:GetPlayers()) do
				if v.AliveBool.Value == true and alivecount >1 then
					workspace.sad:Stop()
					local RoundEndMessage = table.concat(playerlist,",").." has survived"
					workspace.Message.Text = RoundEndMessage
					v.AliveBool.Value = false
					v.leaderstats.Points.Value = v.leaderstats.Points.Value +200
				elseif v.AliveBool.Value == true and alivecount == 1 then
						workspace.Message.Text = "One person only survived - congrats."
					v.AliveBool.Value = false
					v.leaderstats.Points.Value = v.leaderstats.Points.Value +200
						workspace.sad:Stop()
				end
			end
			wait(10)
			map()
		else
				workspace.evil:Play()
				workspace[choice.Name]:Destroy()
				workspace.Message.Text = "The bawlz killed everbody!"
				workspace.sad:Stop()
				wait(10)
				map()
				end
				end
			end
			map()
1 Like