How would I display who won a game?

  1. What do you want to achieve I want to make it so whenever the round starts it grabs all the players and when the round ends it checks who died I think? Im not asking for someone to write a whole script, just point me in the right direction.

  2. What is the issue? I dont know how to make it so whenever the round starts it gets all the playesr and then displays who lost after the round ends.

  3. What solutions have you tried so far? Yes, everywhere for the past week almost.

The script (for reference)

local lobbyLocation = game.Workspace.Lobby2.Position + Vector3.new(0,3,0)
local gameLocation = game.Workspace.Game.Position + Vector3.new(0,3,0)

local ReplicatedStorage = game:GetService('ReplicatedStorage')
local timeEvent = ReplicatedStorage:WaitForChild('TimeEvent')

local tweenService = game:GetService("TweenService")
local Lava = game.Workspace.Other.Lava
local tweeninfo = TweenInfo.new(20,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut,0,false,0)
local tweeninfo2 = TweenInfo.new(1,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut,0,false,0)
local move2 = {
	Position = Vector3.new(0, 24.994, -5.795)
}
local move = {
	Position = Vector3.new(0, -43.124, -5.795)
}
local tween = tweenService:Create(Lava,tweeninfo2,move)
local tween2 = tweenService:Create(Lava,tweeninfo,move2)

local function playGame()
	tween2:Play()
	print("Game Started!")
	local timeAmount = 20
	local timerText = 'Game Time: '
	while timeAmount > 0 do
		timeEvent:FireAllClients(timeAmount, timerText)
		wait(1)
		timeAmount -= 1
	end
end
local function beforeGame()
	print("Game is Starting!")
	local beforeGame = 10
	local beforeText = 'Lava Starts In: '
	while beforeGame > 0 do
		timeEvent:FireAllClients(beforeGame, beforeText)
		wait(1)
		beforeGame -= 1
	end
end

local function playIntermission()
	tween:Play()
	print("Intermission has started!")
	local intermission = 3
	local timerText = ' '
	while intermission > 0 do
		timeEvent:FireAllClients(intermission, timerText)
		wait(1)
		intermission -= 1
	end
end



local function resetPlayers()
	print("Players have been reset!")
	for _, plr in pairs(game.Players:GetChildren()) do

		plr.Character.HumanoidRootPart.CFrame = CFrame.new(lobbyLocation)
	end 
end



local function teleportPlayers()
	print("Players were teleported!")
	for _, plr in pairs(game.Players:GetChildren()) do

		plr.Character.HumanoidRootPart.CFrame = CFrame.new(gameLocation)
	end 
end



while true do

	resetPlayers()

	playIntermission()

	teleportPlayers()
	
	beforeGame()
	
	playGame()

end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

When the game starts, you could insert all players into a table; when a player dies, you’d remove them from the table. Once the game finishes, you reward the player(s) left in the table.

1 Like

Yeah thats what I was thinking, just not sure how I would do it, do you know any tutorials/wiki’s?

1 Like

I could give you the code here. It’d take a bit to write, though. Could you mark me as the solution?

2 Likes

Yeah sure, Thank you, just marked you as the solution

I meant the other post, but thanks anyways.
Here’s the code.

--when the game starts:

for i,v in pairs(game.Players:GetPlayers()) do

table.insert(v, table) --replace 'table' with your table

end

--when the game ends

for i,v in pairs(table) do --replace 'table' with your table

local player = game.Players:FindFirstChild(v)

--reward the player, heres an example

player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 50

end
1 Like

I think it would be better if at the beginning you put the table (empty) called alivePlayers,
In you teleport players function inside the loop add the players then when you reset them which I’m assuming happens when they die you can remove that player from the table

1 Like