Elimination Issue

Hello everyone! I am making a game where each round there is a different obby map and the idea is to eliminate the player with least progress in it.

So, I was using “checkpoints” (they are not really checkpoints) that give players tags with numbers to mark the players’ progress, but someone told me to use an IntValue, and that is what I am using right now…

However, since I started using IntValue, there is 1 problem that I hadn’t seen when using tags. I’ve been testing the game with me and my alt account in the same server.

  • No matter if player A or player B has more progress, the game is always eliminating (changing to Spectators team) the player B. I don’t know why.

Does anyone know why that is happening? I was really frustrated when that happened because that hadn’t happened when I used tag numbers…And by the way, If i press F9 there are no errors in the server nor in the client.

Here is my main script:

And the script for the “checkpoints” (This is for checkpoint3) :

1 Like

Can you paste it using the Lua format instead of screenshots?

Ok I will paste the code not screenshots

Main script:

ServerStorage = game:GetService(“ServerStorage”)
ReplicatedStorage = game:GetService(“ReplicatedStorage”)
Players = game:GetService(“Players”)
local Team = game:GetService(“Teams”)
local Contestants = game.Teams.Contestants
local Spectators = game.Teams.Spectators
local Completed = game.Teams.Completed
local cs = game:GetService(“CollectionService”)

Maps = ServerStorage:WaitForChild(‘Maps’):GetChildren()
Status = ReplicatedStorage:WaitForChild(‘Status’)

local players = game:GetService(“Players”)
players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local stageValue = Instance.new(“IntValue”, char)
stageValue.Name = “Stage”
end)
end)

while true do

--Intermission

local Countdown = 10 -- ten second intermission, make this as long as you want

repeat wait(1)
	Countdown = Countdown - 1

	Status.Value = 'Intermission : '..Countdown
until Countdown <= 0

--Choose the map.

Status.Value = 'Choosing Map...'

local ChosenMap = Maps[math.random(1, #Maps)]:Clone()
local Spawns = ChosenMap:FindFirstChild('Spawns'):GetChildren()
local RandomSpawn = Spawns[math.random(1, #Spawns)]
local LobbySpawns = game.Workspace.Lobby:FindFirstChild('LobbySpawns'):GetChildren()
local RandomLobbySpawn = LobbySpawns[math.random(1, #LobbySpawns)]

wait(5) -- little pause, make this as long as you want

ChosenMap.Parent = workspace
Status.Value =  'Next Map Is: '

wait(2) -- little pause, make this as long as you want

Status.Value = ChosenMap.Name

wait(2) -- little pause, make this as long as you want

--teleport the players

for _, Player in pairs(Players:GetChildren())do
	if Player.Character and Player.Character:FindFirstChild('Humanoid') then
		Player.Character.HumanoidRootPart.CFrame = RandomSpawn.CFrame
	end
end

for _, Player in pairs(Players:GetChildren())do
	Player.Team = Contestants
end

-- Reassign countdown based on chosen map's Duration value
Countdown = ChosenMap:FindFirstChild("Duration").Value

repeat wait(1)
	Countdown = Countdown - 1
	
	local minutes = math.floor(Countdown / 60)
	local seconds = math.floor(Countdown % 60)

	Status.Value = string.format("Time left : %.2d:%.2d", minutes, seconds)
until Countdown <= 0

--Teleport back to lobby

for _, Player in pairs(Players:GetChildren())do
	if Player.Character and Player.Character:FindFirstChild('Humanoid') and Player.Team == Contestants then
		Player.Character.HumanoidRootPart.CFrame = RandomLobbySpawn.CFrame
	end
end

for _, Player in pairs(Players:GetChildren())do
	Player.Team = Completed
end

local slowestPlayer = nil
local lowestStage = math.huge -- This will ensure that the first check will always pass

for _, player in pairs(Players:GetPlayers()) do
	local char = player.Character
	if not char then continue end
	
	local stage = char.Stage.Value
	if stage < lowestStage then
		lowestStage = stage
		slowestPlayer = player
	end
end

for _, Player in pairs(Players:GetChildren())do
	slowestPlayer.Team = Spectators
end
	
Status.Value = 'The eliminated player is: '

wait(2) -- little pause, make this as long as you want

Status.Value = slowestPlayer.Name

wait(2) -- little pause, make this as long as you want

ChosenMap:Destroy()

end

Checkpoint3:

local stageNumber = 3 – Change this to whatever stage number you’re using

script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
if hit.Parent.Stage.Value < stageNumber then
hit.Parent.Stage.Value = stageNumber
end
end
end)

By the way in the checkpoint script it was written > and now it is < because now i corrected it

1 Like

Is the player B being eliminated as soon as the round starts or quickly after the round starts?

No, he was being eliminated when the round ended, no matter who got further, but now it seems like the elimination is random, sometimes player A is being eliminated too…

Put a print in the for loop. I somewhat expect that it’s because the for loop only runs once, meaning the player chosen as the slowest player is chosen at the beginning of the round, no matter the end result.

Oh okay, how can i write that?

Is the countdown in the repeat until loop for the beginning of the round, or is it the timer for the round itself?

1 Like

I think the countdown is just the thing that makes the timer appear in the screen, because in the intermission it is a time, in the round its other etc

Put print(slowestPlayer.Name) in the stage for loop, and also print(player.Name, stage).

1 Like

Wait, but in what part of the script do I write that?

for _, player in pairs(Players:GetPlayers()) do
	local char = player.Character
	if not char then continue end
	
	local stage = char.Stage.Value
print(player.Name, stage)
	if stage < lowestStage then
		lowestStage = stage
		slowestPlayer = player
print(slowestPlayer.Name, "For loop")
	end
end
print(slowestPlayer.Name, "For loop ended")

And then copy and paste the output when you finish the round.

Also remove the for loop here:

for _, Player in pairs(Players:GetChildren())do
	slowestPlayer.Team = Spectators
end

-- Make it so that it's like this:

slowestPlayer.Team = Spectators
1 Like

Ok so I was in the studio alone and when the round ended the output said:

10:15:33.644 Laverr54 7 - Server - MapPicker:98
10:15:33.644 Laverr54 For loop - Server - MapPicker:102
10:15:33.644 Laverr54 For loop ended - Server - MapPicker:105

Now i will test with my alt account XD

Do you not need multiple players for the game to work properly? Otherwise if you are alone you will always be the slowest player.

Oh I once saw a video where a guy was in the studio and he played with 4 players inside the studio and I don’t know how to do that? Is that multiplying?

If you go on ‘Test’ you should see options to start a new server with multiple ‘players’.

Uhh so I was playing with my alt account and he was ahead and then fell and he was eliminated I don’t know if it is because he fell or because the game chose him as slowest player in the beginning… I will test more times

Bruh now he was ahead and didn’t fall and still was eliminated

Ok, I realised a pattern… In the first round, the player with least progress in being eliminated, and in the second round too, but then player B is eliminated all the time :confused: I have no idea why… I am suspecting maybe its because I am just playing one map (because it would be easier to test)… If i put all the 8 maps in the serverstorage maybe in the other maps it will work

Try this:

-- at the top of the script

local completed = false

-- repeat until countdown
repeat wait(1)
-- countdown script
completed = true
until Countdown <= 0

if completed then
 -- the rest of the script

Remember to make completed false at the end of the script.

1 Like

Uh, so do i put this all together in the beginning or the local completed in beginning and the rest in the middle? Also how can i make it false in the end?