How can I make a string value show the winners of a round?

Hello! I have this game. I want it to show the match winners. Example: like Epic Minigames:

How I want it to work?

Here is my script:

local status = game.ReplicatedStorage:WaitForChild("Status")

local function loop()	
	status.Value = "Intermission: 15"
	wait(1)
	status.Value = "Intermission: 14"
	wait(1)
	status.Value = "Intermission: 13"
	wait(1)
	status.Value = "Intermission: 12"
	wait(1)
	status.Value = "Intermission: 11"
	wait(1)
	status.Value = "Intermission: 10"
	wait(1)
	status.Value = "Intermission: 9"
	wait(1)
	status.Value = "Intermission: 8"
	wait(1)
	status.Value = "Intermission: 7"
	wait(1)
	status.Value = "Intermission: 6"
	wait(1)
	status.Value = "Intermission: 5"
	wait(1)
	status.Value = "Intermission: 4"
	wait(1)
	status.Value = "Intermission: 3"
	wait(1)
	status.Value = "Intermission: 2"
	wait(1)
	status.Value = "Intermission: 1"
	wait(1)
	status.Value = "Loading Map..."
	wait(2)
	
	local mapDirectory = game.ServerStorage.Maps
	local maps = mapDirectory:getChildren()
	if #maps == 0 then 
		print("Maps not found! Selfremoving...")
		script:remove()
		return
	end 
	local pickedMap = maps[math.random(1, #maps)]
	local pickedMapClone = pickedMap:clone()
	pickedMapClone.Parent = game.Workspace
	pickedMapClone:makeJoints()
	pickedMapClone:MoveTo(Vector3.new(42.5, 145.6, 2941.25))
	wait(2)
	status.Value = "Map loaded: ".. pickedMap.Name
	wait(4)
	
	status.Value = "Starting Game"
	wait(3)
	
	local plrdrop = game.Workspace.Floor
	
	local walls = workspace.Walls:GetChildren()
	
	for i, v in pairs(game.Players:GetChildren()) do
		v.Character:MoveTo(Vector3.new(38, 164.5, 2934.25))
	end
	status.Value = "Game will start in 10"
	wait(1)
	status.Value = "Game will start in 9"
	wait(1)
	status.Value = "Game will start in 8"
	wait(1)
	status.Value = "Game will start in 7"
	wait(1)
	status.Value = "Game will start in 6"
	wait(1)
	status.Value = "Game will start in 5"
	wait(1)
	status.Value = "Game will start in 4"
	wait(1)
	status.Value = "Game will start in 3"
	wait(1)
	status.Value = "Game will start in 2"
	wait(1)
	status.Value = "Game will start in 1"
	wait(1)
	
	plrdrop.Transparency = 1
	plrdrop.CanCollide = false
	
	for _, wall in pairs(walls) do
		if wall:IsA("Part") then
			wall.CanCollide = false
		end
	end
	
	status.Value = "60"
	wait(1)
	status.Value = "59"
	wait(1)
	status.Value = "58"
	wait(1)
	status.Value = "57"
	wait(1)
	status.Value = "56"
	wait(1)
	status.Value = "55"
	wait(1)
	status.Value = "54"
	wait(1)
	status.Value = "53"
	wait(1)
	status.Value = "52"
	wait(1)
	status.Value = "51"
	wait(1)
	status.Value = "50"
	wait(1)
	status.Value = "49"
	wait(1)
	status.Value = "48"
	wait(1)
	status.Value = "47"
	wait(1)
	status.Value = "46"
	wait(1)
	status.Value = "45"
	wait(1)
	status.Value = "44"
	wait(1)
	status.Value = "43"
	wait(1)
	status.Value = "42"
	wait(1)
	status.Value = "41"
	wait(1)
	status.Value = "40"
	wait(1)
	status.Value = "39"
	wait(1)
	status.Value = "38"
	wait(1)
	status.Value = "37"
	wait(1)
	status.Value = "36"
	wait(1)
	status.Value = "35"
	wait(1)
	status.Value = "34"
	wait(1)
	status.Value = "33"
	wait(1)
	status.Value = "32"
	wait(1)
	status.Value = "31"
	wait(1)
	status.Value = "30"
	wait(1)
	status.Value = "29"
	wait(1)
	status.Value = "28"
	wait(1)
	status.Value = "27"
	wait(1)
	status.Value = "26"
	wait(1)
	status.Value = "25"
	wait(1)
	status.Value = "24"
	wait(1)
	status.Value = "23"
	wait(1)
	status.Value = "22"
	wait(1)
	status.Value = "21"
	wait(1)
	status.Value = "20"
	wait(1)
	status.Value = "19"
	wait(1)
	status.Value = "18"
	wait(1)
	status.Value = "17"
	wait(1)
	status.Value = "16"
	wait(1)
	status.Value = "15"
	wait(1)
	status.Value = "14"
	wait(1)
	status.Value = "13"
	wait(1)
	status.Value = "12"
	wait(1)
	status.Value = "11"
	wait(1)
	status.Value = "10"
	wait(1)
	status.Value = "9"
	wait(1)
	status.Value = "8"
	wait(1)
	status.Value = "7"
	wait(1)
	status.Value = "6"
	wait(1)
	status.Value = "5"
	wait(1)
	status.Value = "4"
	wait(1)
	status.Value = "3"
	wait(1)
	status.Value = "2"
	wait(1)
	status.Value = "1"
	wait(1)
	status.Value = "Time's Up!"
	
	local lander = game.ServerStorage.lander:Clone()
	lander.Parent = game.Workspace
	pickedMapClone:Destroy()
	lander.Transparency = 1
	
	local XP = game.ServerStorage.XP:Clone()
	XP.Parent = game.Workspace
	XP.Position = Vector3.new(41.5, 138.8, 2943.25)
	
	local function cleanup(thing1, thing2)
		thing1:Destroy()
		thing2:Destroy()
	end
	
	wait(3)
	status.Value = "Returning remaining players to lobby..."
	
	wait(3)
	
	for i, v in pairs(game.Players:GetChildren()) do
		v:LoadCharacter()
	end
	
	plrdrop.CanCollide = true
	
	for _, wall in pairs(walls) do
		if wall:IsA("Part") then
			wall.CanCollide = true
		end
	end
	
	return cleanup(XP, lander)
	
end

while true do loop() end

I know, this is a very long script lol.

I have this map. When the time is up, If there is a/are player(s) on the lander (the thing that the players will land on when the map disappears), then status.Value will show the name(s) of the winner(s). It would be very appreciating if you know how to do something like this.

If you have a list of winners ready, you can do something like this:

local plrtable = {"username1", "username2", "username3"}
status.Value = "Winners: "
for i, plr in ipairs(plrtable) do
	if i == #plrtable then
		status.Value ..= plr --end example: Winners: username3
	else
		status.Value ..= plr .. ", " --end example: Winners: username1, 
	end
end
print(status.Value) --expected output: Winners: username1, username2, username3

Referenced from Lua Globals

1 Like

Alternatively, you could also do this using table.concat:

string.format("Winner(s): %s", table.concat(winnersTable, ", "))

Assuming winnersTable is an array containing strings which represent the players’ names.

1 Like

Your coding style is very messy, for your intermission, you should use a loop such as,

for x = 1,16 do
    if x < 16 then
        status.Value = ("Intermission: " .. x)
    else
        status.Value = "Loading Map..."
    end
end

Now for the winners,

local winners

table.insert(winners, playerName)

when the game is finished

status.Value = "Winners "
for _, player in ipairs(winners) do
	status.Value ..= player
end```
1 Like

This is not done correctly.
It should be written like this:

status.Value = "Winners "
for _, player in ipairs(winners) do
	status.Value ..= player .. ", "
end
1 Like

You could also simplify your countdowns to something like this:

local countdown = 60
status.Value = "60"
while wait(1) and countdown >= 0 do
	status.Value = tostring(countdown)
	countdown -= 1
end

And, for the intermission:

local countdown = 10
status.Value = "10"
while wait(1) and countdown >= 0 do
	status.Value = "Game will start in " .. tostring(countdown)
	countdown -= 1
end
1 Like

Ok, I’ll try each when I get the time. Thank you.

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