ok let me explain this in detail:
So i have a round system already and a timer too
there is a part of the timer script: (its server side and its seperate from that script before)
while DeathMV.Value == true do -- changed from the server script (scroll down to the server script)
local DeathMatchPrep = true
DeathTimer:FireAllClients(DeathMatchPrep, DeathMatchPrepTime)
DeathMatchPrepTime = SDeathMatchPrepTime
while DeathMatchPrepTime > 0 do
wait(1)
DeathMatchPrepTime -= 1
DeathTimer:FireAllClients(DeathMatchPrep, DeathMatchPrepTime)
end
DeathMatchPrepTime = SDeathMatchPrepTime
CountDown = SCountDown
DeathMatch:Fire()
CD:FireAllClients(CountDown)
while CountDown > 0 do
wait(1)
CountDown -= 1
CD:FireAllClients(CountDown)
end
CountDown = SCountDown
DeathMatchPrep = false
DeathTimer:FireAllClients(DeathMatchPrep, DeathMatchTime)
DeathMatchTime = SDeathMatchTime
while DeathMatchTime > 0 do
wait(1)
DeathMatchTime -= 1
DeathTimer:FireAllClients(DeathMatchPrep,DeathMatchTime)
end
DeathMatchTime = SDeathMatchTime
DeathMV.Value = false
end
The reason i didnt use for loops bcs i thought there is no reason to.
here is the whole tie/Deathmatch function:
elseif #DrawPlayers <= 4 then -- 2 or more people have same kills somehow
local DeathMatch = game.ReplicatedStorage.Events.RoundEvents:WaitForChild("DeathMatch")
local DMV = game.ReplicatedStorage.Round:WaitForChild("DeathMatch")
local Arena = game.ReplicatedStorage.Maps:WaitForChild("DeathMatchArena")
local Event = false
DMV.Value = true
DeathMatch.Event:Wait() --waits until the timer starts
local Duplicate = Arena:Clone()
local Spawns = Arena.Spawns:GetChildren()
Duplicate.Parent = game.Workspace
for i = 1, #DrawPlayers do --teleports the tied players
if DrawPlayers[i]:WaitForChild("playing").Value == false then
DrawPlayers[i]:WaitForChild("playing").Value = true
end
DeathMUI:FireClient(DrawPlayers[i]) --disables some UI
DrawPlayers[i].Character:FindFirstChild("HumanoidRootPart").CFrame = Spawns[i].CFrame + Vector3.new(0,10,0)
end
while DMV.Value == true do
while #DrawPlayers ~= 1 do
local player = Hdied.Event:Wait()
print(player)
local e = table.find(DrawPlayers, player) --Checks if player is one of the DrawPlayers
if e then
table.remove(DrawPlayers, e)
end
end
DMV.Value = false --if all opponents died the timer stops with this before it has run out
end
if #DrawPlayers >= 2 then
DMMSG:FireClient()
else
print(tostring(DrawPlayers[1].Name).. " Won the Deathmatch!!")
Win:Fire(DrawPlayers[1])
WinMsg:FireAllClients(DrawPlayers[1],Draw, AbsouluteDraw , nobody, DrawPlayers[1], #DrawPlayers)
end
Duplicate:Destroy()
for i = 1, #DrawPlayers do
local SpawnsE = game.Workspace.All.Map.Spawns:GetChildren()
DrawPlayers[i].Character:FindFirstChild("HumanoidRootPart").CFrame = SpawnsE[i].CFrame + Vector3.new(0,10,0)
end
The DVM.Value
loop is in a function in a seperate script as the timer one, the whole script actually worked with the timer script but the actuall problem is why it doesnt stop
i mean maybe for loops was a better option but it worked until now
And the code
actually works because if all the players are removed until 1 is left, it cancels the loop
“~=” equals “is not”