-
Im trying to make round system
-
for some reasons when all people dying next round won’t teleport people who died
-- Timer Script
local Rep = game.ReplicatedStorage
local RoundStarted = Rep.RoundStarted
local InRound = script.Parent.Parent.Parent.Parent.InRound
local Character = script.Parent.Parent.Parent.Parent.Character
local TotalPeople = Rep.TotalPeopleInRound
function Format(Int)
return string.format("%02i", Int)
end
function convertToMS(Seconds)
local Minutes = (Seconds - Seconds%60)/60
Seconds = Seconds - Minutes*60
return Format(Minutes)..":"..Format(Seconds)
end
RoundStarted.Changed:Connect(function(NewValue)
if NewValue == true then
for i = 1,10 do
if RoundStarted.Value == false then
script.Parent.Text = "Round Ended"
wait(1)
break
else
script.Parent.Text = "Round In Progress "..convertToMS(10-i)
wait(1)
end
end
if InRound.Value == true then
print("Player Was in the round")
Character:FindFirstChild("HumanoidRootPart").Position = game.Workspace.SpawnLocation.Position
InRound.Value = false
end
wait(1)
if Character:FindFirstChild("ClassicSword") then
print("Found Sword")
Character.ClassicSword:Destroy()
elseif script.Parent.Parent.Parent.Parent.Backpack:FindFirstChild("ClassicSword") then
script.Parent.Parent.Parent.Parent.Backpack.ClassicSword:Destroy()
end
if TotalPeople.Value ~= 0 then
print("People is not 0 ")
TotalPeople.Value = TotalPeople.Value - 1
end
print("Round is over")
RoundStarted.Value = false
else
wait(1)
for i = 1,5 do
if RoundStarted.Value == true then
script.Parent.Text = "Round Started"
wait(1)
break
else
script.Parent.Text = "Round Starting in "..5-i
wait(1)
end
end
print("Giving Player A Sword")
local SwordClone = Rep.ClassicSword:Clone()
print("Changing InRound to true")
InRound.Value = true
print("Moving Sword into the player Character")
SwordClone.Parent = Character
print("Adding One More Player Into TotalPeople")
TotalPeople.Value = TotalPeople.Value + 1
print("Teleporting Player")
Character:FindFirstChild("HumanoidRootPart").CFrame = game.Workspace.TrashCan.CFrame
print("Making Round Start")
RoundStarted.Value = true
end
end)
--Script That Checks if player died
local RoundStarted = game.ReplicatedStorage.RoundStarted
local TotalPeopleInRound = game.ReplicatedStorage.TotalPeopleInRound
RoundStarted.Changed:Connect(function(NewValue)
print("RoundStarted Changed"..tostring(NewValue))
if NewValue == true then
print("Round Is Started")
for i,v in pairs(game.Players:GetChildren()) do
print("Getting Players")
if v.InRound.Value == true then
print("Player Is InRound")
v.Character.Humanoid.Died:Connect(function()
print("Player Died")
print("Round is not over")
v.InRound.Value = false
print("Removed Player From InRound")
TotalPeopleInRound.Value = TotalPeopleInRound.Value - 1
print("Removed one from total people")
end)
end
end
end
end)
TotalPeopleInRound.Changed:Connect(function(NewValue)
print("TotalPeople Changed"..tostring(NewValue))
if NewValue == 0 then
print("Value is 0")
RoundStarted.Value = false
print("Round is now ended")
end
end)