I have this code
wait(2)
local Players = game.Players
local ReplicatedStorage = game.ReplicatedStorage
local ServerStorage = game.ServerStorage
local ChangeGUITextEvent = ReplicatedStorage.ChangeGUIText
local Maps = {workspace.MapTeleports.Map1, workspace.MapTeleports.Map2}
local DealDamage = ReplicatedStorage["5&mw5EE'5jnKxmw3"]
local playersLeft = ReplicatedStorage.PLFT
local LastMap = workspace.MapTeleports.Map1
local HasWon = false
function TeleportPlayer(player, Character, SpawnPoints)
local SpotsToSpawnIn = {}
local TheirSpot
for i, v in pairs(SpawnPoints:GetChildren()) do
table.insert(SpotsToSpawnIn, v)
end
for i, v in pairs(SpotsToSpawnIn) do
TheirSpot = SpotsToSpawnIn[math.random(1, #SpotsToSpawnIn)]
end
Character.HumanoidRootPart.CFrame = TheirSpot.CFrame
end
function WhileTrueLoop(player)
spawn(function()
while true do
repeat wait() until #Players:GetPlayers() >= 2
wait(2)
ChangeGUITextEvent:FireAllClients("intermisson")
wait(5)
ChangeGUITextEvent:FireAllClients("")
for _, vPlayer in pairs(game.Players:GetPlayers()) do
if vPlayer then
vPlayer.KillsThatRound.Value = 0
end
end
for _,v in pairs(workspace:GetChildren())do
if v.Name == "Handle"then
v:Destroy()
end
end
wait(5)
local Character = player.Character or player.CharacterAdded:Wait()
local ChosenMap
if LastMap == workspace.MapTeleports.Map1 then
ChosenMap = workspace.MapTeleports.Map2
elseif LastMap == workspace.MapTeleports.Map2 then
ChosenMap = workspace.MapTeleports.Map1
end
TeleportPlayer(player, Character, ChosenMap)
local UnclonedPlayersKnife = ServerStorage.Knifes:FindFirstChild(player.OtherValues.CurrentKnife.Value)
if UnclonedPlayersKnife ~= nil then
local PlayersKnife = UnclonedPlayersKnife:Clone()
PlayersKnife.Parent = player.Backpack
else
local PlayersKnife = ServerStorage.Knifes:FindFirstChild("ClassicKnife"):Clone()
PlayersKnife.Parent = player.Backpack
end
ChangeGUITextEvent:FireAllClients("The map chosen was " .. ChosenMap.Name .. ".")
playersLeft.Value = #Players:GetPlayers() --resets this value
DealDamage.OnServerEvent:Connect(function(MyPlayer, HitPlayer)
playersLeft.Value = playersLeft.Value - 1
if playersLeft.Value == 1 then
HasWon = true
ChangeGUITextEvent:FireAllClients(MyPlayer.Name .. " has won!")
end
end)
if HasWon then
break
end
wait(5)
ChangeGUITextEvent:FireAllClients("")
wait(95)
end
end)
end
Players.PlayerAdded:Connect(function(player)
wait(3)
WhileTrueLoop(player)
spawn(function()
while wait() do
if HasWon == true then
HasWon = false
for _, v in pairs(game.Players:GetPlayers()) do
local vCharacter = v.Character
vCharacter.Humanoid.Health = 0
wait(3)
WhileTrueLoop(v)
end
end
end
end)
end)
but it will only teleport the player who won (sorry for code bomb)
