so the code works normal until round time finishes when it does the timer just starts going in the negative numbers instead of starting over
local RS = game:GetService("ReplicatedStorage")
local uiChangeEvent = RS.Events.Remote.UiRoundEvent
local Time = game.ReplicatedStorage.RoundData.Time
local ball = workspace.Lobby.ball
local redTeam = game.Teams.RedTeam
local blueTeam = game.Teams.RedTeam
local player = game.Players.LocalPlayer
local Players = game:GetService("Players")
local Client = Players:GetPlayerFromCharacter(player)
local Teams = game:GetService("Teams")
local teams = Teams:GetTeams()
--SETTING--
local ITimeBeforeTeleport = 10
local IPreparingTime = 10
local IRoundTime = 10
local IChooseMapTime = 10
--END--
local TimeBeforeTeleport = ITimeBeforeTeleport
local RoundTime = IRoundTime
local PreparingTime = IPreparingTime
local ChooseMapTime = IChooseMapTime
function giveTeamCoins(teamColor,amount)
for i,v in ipairs(game.Players:GetChildren()) do
if v.TeamColor == BrickColor.new(teamColor) then
v.leaderstats.Coins.Value = v.leaderstats.Coins.Value + amount
end
end
end
function killPlayers()
for _, player in pairs(game.Players:GetChildren()) do
local char = player.Character
if char:WaitForChild("Humanoid").Health > 0 then
char:WaitForChild("Humanoid").Health = 0
end
end
end
while true do
Time.Value = ITimeBeforeTeleport
RS.Events.Remote.Intermission:FireAllClients(player, nil)
repeat -- intermission
task.wait(1)
Time.Value -= 1
TimeBeforeTeleport -= 1
until TimeBeforeTeleport == 0
TimeBeforeTeleport = ITimeBeforeTeleport
Time.Value = IChooseMapTime
RS.Events.Remote.VotingTime:FireAllClients(player, nil)
repeat -- Voting
task.wait(1)
Time.Value -= 1
TimeBeforeTeleport -= 1
until TimeBeforeTeleport == 0
ChooseMapTime = IChooseMapTime
Time.Value = IPreparingTime
workspace.SpawnLocation.Position = Vector3.new(60.489, 1.75, -16.019)
workspace.SpawnLocation.Transparency = 1
workspace.SpawnLocation.Decal.Transparency = 1
wait(0.5)
killPlayers()
task.wait(0.1)
RS.Events.Remote.PrepTime:FireAllClients(player, nil)
task.wait(1)
workspace.SpawnLocation.Position = Vector3.new(-91.107, 48.081, -17.446)
workspace.SpawnLocation.Transparency = 0
workspace.SpawnLocation.Decal.Transparency = 0
task.wait(0.1)
repeat -- preptime
task.wait(1)
Time.Value -= 1
PreparingTime -= 1
until PreparingTime == 0
PreparingTime = IPreparingTime
Time.Value = IRoundTime
ball.Anchored = false
ball.Transparency = 0
ball.Velocity = Vector3.new()
ball.AssemblyAngularVelocity = Vector3.new()
RS.Events.Remote.RoundTime:FireAllClients()
repeat -- round time
task.wait(1)
Time.Value -= 1
RoundTime -= 1
until RoundTime == 0
RoundTime = IRoundTime
killPlayers()
ball.Anchored = true
ball.Position = Vector3.new(60.366, 7.596, -16.019)
ball.Velocity = Vector3.new()
ball.AssemblyAngularVelocity = Vector3.new()
ball.Transparency = 1
end