Don’t use touched rather use ray cast or at end of time find the magnitude of vector between the end point and the coordinates of the humanoid. The player with large magnitude is sent to spectator team.
Put everything where I said in comments. You can make it false by doing completed = false at the end of the while true loop.
So i typed in these places ( I don’t know if i put in the right places)
local completed = false
ServerStorage = game:GetService(“ServerStorage”)
ReplicatedStorage = game:GetService(“ReplicatedStorage”)
Players = game:GetService(“Players”)
local Team = game:GetService(“Teams”)
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
repeat wait(1)
-- countdown script
completed = true
until Countdown <= 0
wait(2) – little pause, make this as long as you want
ChosenMap:Destroy()
if completed then
completed = false
end
end
But what does this do?
By the way I just realised that only in the 1st round it eliminates the right player, and then it always eliminates player B, i wonder why only works in first round??
That ain’t it chief.
local ServerStorage = game:GetService(“ServerStorage”)
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local 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”)
local Maps = ServerStorage:WaitForChild(‘Maps’):GetChildren()
local 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)
-- completed
local completed = false
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
if Countdown <= 0 then
completed = true
end
if completed == true then
--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
slowestPlayer.Team = Spectators
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()
completed = false
end
end
I’m not sure whether that will work, but honestly it’s hard to grasp what’s going wrong given the fact you are clearly quite new to Lua programming.
Ok I will test it, if you want I can allow team build for you then I think it will be easier
So i tested it, and player B was in front in the first 3 rounds, and in the 4th round player A was in front and player A was eliminated all the time.
Do the same with these prints:
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
print(slowestPlayer.Name, stage, "Before loop")
end
end
print(slowestPlayer.Name, "After loop")
Hey i realised why it wasn’t working. It was because the players’ stage number wasn’t removed from them. I discovered that putting print(0), print(4) etc in the checkpoints, when the new round started the number stayed high and it wouldn’t go back to 0.
Now I will make it remove the stage number from the players. Thanks for the help!