Serverside
local values = game:GetService('ReplicatedStorage').Values
wait(1)
local players = game.Players:GetPlayers()
local interval = 1
local length = 30
local minimum = 0
local roundEnded = false
local roundDuration = values:FindFirstChild('roundDuration')
local roundMax = roundDuration.Value
local mapFolder = game:GetService('ReplicatedStorage').Maps
-- Insert maps into table
local maps = {}
for _,map in pairs(mapFolder:GetChildren()) do
table.insert(maps,1,map)
end
function servercountdown()
-- Countdown script
while wait(interval) do
for i = length,minimum,-1 do
local intermissionTime = game:GetService('ReplicatedStorage').Values:WaitForChild('IntermissionTime')
intermissionTime.Value = i
wait(1)
end
wait(2)
local map = maps[math.random(1,#maps)]
map.Parent = workspace
for _,player in pairs(players) do
print(player.Name)
player.Character.HumanoidRootPart.CFrame = map.PrimaryPart.CFrame
end
for i = roundMax,minimum,-1 do
roundDuration.Value -= 1
wait(1)
if roundDuration.Value == 110 then
for _,player in pairs(game.Players:GetChildren()) do
local gunclone = game.ReplicatedStorage["Laser Gun"]:Clone()
gunclone.Parent = player.Backpack
end
end
if roundDuration.Value == 0 then
print("Round ended")
map.Parent = game.ReplicatedStorage
for _,player in pairs(players) do
print(player.Name)
player.Character.HumanoidRootPart.CFrame = workspace.SpawnLocation.CFrame
end
roundEnded = true
for _,player in pairs(game.Players:GetChildren()) do
local lasergun = player.Character:FindFirstChild("Laser Gun") or player.Backpack:FindFirstChild("Laser Gun")
if not lasergun then
print("Laser gun not found, couldn't destroy.")
else
lasergun:Destroy()
end
end
end
end
end
end
local svrcountdown = coroutine.create(servercountdown)
local success,errormessage = coroutine.resume(svrcountdown)
while wait() do
if roundEnded == true then
local newsvrcountdown = coroutine.create(servercountdown)
local success2,errormessage2 = coroutine.resume(newsvrcountdown)
if success2 then
game.ReplicatedStorage.Values.IntermissionTime.Value = 30
game.ReplicatedStorage.Values.roundDuration.Value = 120
roundEnded = false
else
warn(errormessage2)
end
end
end
Client-side
local screenGUI = script.Parent.Parent
script.Parent.ResetOnSpawn = false
wait(1)
local values = game:GetService('ReplicatedStorage').Values
local intermissionTime
local roundEnded = false
local roundDuration
local text = script.Parent.Frame.Intermission.Text
function setIntermission()
while wait(.069) do
intermissionTime = values:FindFirstChild('IntermissionTime')
roundDuration = values:FindFirstChild('roundDuration')
script.Parent.Frame.Intermission.Text = "Intermission: "..intermissionTime.Value.." seconds left."
if intermissionTime.Value == 0 then
print("Intermission over")
script.Parent.Frame.Intermission.Text = "Game started!"
wait(2)
break
end
end
while wait(.069) do
roundDuration = values:FindFirstChild('roundDuration')
script.Parent.Frame.Intermission.Text = "Time Left: "..roundDuration.Value.." seconds."
if roundDuration.Value == 0 then
print("Round over")
script.Parent.Frame.Intermission.Text = "Game over!"
wait(2)
roundEnded = true
break
end
end
end
local intermissionCoro = coroutine.create(setIntermission)
local success,errormessage = coroutine.resume(intermissionCoro)
if success then
print('Coroutine ran successfully!')
else
print("Coroutine SUCKS!")
end
while wait() do
local newCoro = coroutine.create(setIntermission)
if roundEnded == true then
print("Round Over, starting coroutine")
local success2,errormessage2 = coroutine.resume(newCoro)
if success2 then
print('Coroutine ran successfully!')
roundEnded = false
else
print("Coroutine SUCKS!")
warn(errormessage)
end
end
end
Works as scripted in studio as well as in-game except the teleport / humanoidrootpart cframe change isnt working in-game :/

6 comments
i have the same problem but with datastores. Datastore gets data perfectly in roblox studio but it doesnt work in game. I think it may be roblox issues but idk
you have to enable API services person above me
you have to enable API services person above me
you have to enable API services person above me game settings > security > enable api services
you have to enable API services person above me game settings > security > enable api services
sorry it lagged and it posted multiple times