Well, most of the parts don’t work in studio you are able to attack with a keybind such as Z, X, or C, and sprint using shift but not in roblox. Furthermore, you can’t interact with UI and most of it doesn’t load apart from that mostly everything else works. This is the timer code:
local Roact = require(game.ReplicatedStorage.Dependencies.roact)
local RemoteEvents = game.ReplicatedStorage.Asterick.game.Shared.RemoteEvents :: any
local TimerScreen = Roact.Component:extend("TimerScreen")
function TimerScreen:init()
self:setState({
TimeReamning = "00:00",
State = nil,
Player = game:GetService("Players").LocalPlayer,
})
end
function TimerScreen:didMount()
local TimeCon = RemoteEvents.OnRoundStateUpdate.OnClientEvent:Connect(function(Time, State)
self:setState({
TimeRemaining = Time,
State = State,
Player = game:GetService("Players").LocalPlayer,
})
if Time == "00:00" then
self:setState({
State = "Setting up the round",
})
end
end)
end
function TimerScreen:render()
return Roact.createElement("ScreenGui", {
Enabled = true,
IgnoreGuiInset = true,
ResetOnSpawn = false,
}, {
TimerFrame = Roact.createElement("Frame", {
Size = UDim2.new(0.559, 0, 0.201, 0),
AnchorPoint = Vector2.new(0.5, 0.5),
Position = UDim2.new(0.5, 0, 0.061, 0),
Transparency = 1,
}, {
UIAspectRatioConstraint = Roact.createElement("UIAspectRatioConstraint", {
AspectRatio = 5.36,
AspectType = Enum.AspectType.FitWithinMaxSize,
DominantAxis = Enum.DominantAxis.Width,
}),
}),
TopText = Roact.createElement("TextLabel", {
BackgroundTransparency = 0.5,
AnchorPoint = Vector2.new(0.5, 0.5),
BackgroundColor3 = Color3.fromRGB(0, 0, 0),
Position = UDim2.new(0.499, 0, 0.018, 0),
Size = UDim2.new(0.343, 0, 0.06, 0),
TextSize = 38,
TextScaled = true,
Text = self.state.State,
TextXAlignment = Enum.TextXAlignment.Center,
TextYAlignment = Enum.TextYAlignment.Center,
TextColor3 = Color3.fromRGB(255, 255, 255),
Font = Enum.Font.Unknown,
FontFace = Font.new("rbxasset://fonts/families/PressStart2P.json", Enum.FontWeight.Regular),
}, {
UICorner = Roact.createElement("UICorner", {
CornerRadius = UDim.new(0, 10),
}),
UIStroke = Roact.createElement("UIStroke", {
ApplyStrokeMode = Enum.ApplyStrokeMode.Contextual,
Thickness = 2,
Color = Color3.fromRGB(0, 0, 0),
}),
UIStroke2 = Roact.createElement("UIStroke", {
ApplyStrokeMode = Enum.ApplyStrokeMode.Border,
Thickness = 2,
Color = Color3.fromRGB(255, 255, 255),
}),
}),
BottomText = Roact.createElement("TextLabel", {
BackgroundTransparency = 0.5,
AnchorPoint = Vector2.new(0.5, 0.5),
BackgroundColor3 = Color3.fromRGB(0, 0, 0),
Position = UDim2.new(0.5, 0, 0.085, 0),
Size = UDim2.new(0.179, 0, 0.05, 0),
TextSize = 59,
TextWrapped = true,
TextScaled = true,
Text = self.state.TimeRemaining,
TextXAlignment = Enum.TextXAlignment.Center,
TextYAlignment = Enum.TextYAlignment.Center,
TextColor3 = Color3.fromRGB(255, 255, 255),
Font = Enum.Font.Unknown,
FontFace = Font.new("rbxasset://fonts/families/PressStart2P.json", Enum.FontWeight.Regular),
}, {
ImageLabel = Roact.createElement("ImageLabel", {
AnchorPoint = Vector2.new(0.5, 0.5),
Position = UDim2.new(0.133, 0, 0.53, 0),
Size = UDim2.new(0.145, 0, 0.94, 0),
Image = "rbxassetid://91876820748682",
BackgroundColor3 = Color3.fromRGB(255, 255, 255),
BackgroundTransparency = 1,
BorderColor3 = Color3.fromRGB(0, 0, 0),
}),
ImageLabel2 = Roact.createElement("ImageLabel", {
AnchorPoint = Vector2.new(0.5, 0.5),
Position = UDim2.new(0.87, 0, 0.53, 0),
Size = UDim2.new(0.145, 0, 0.94, 0),
Image = "rbxassetid://91876820748682",
BackgroundColor3 = Color3.fromRGB(255, 255, 255),
BackgroundTransparency = 1,
BorderColor3 = Color3.fromRGB(0, 0, 0),
}),
UICorner = Roact.createElement("UICorner", {
CornerRadius = UDim.new(0, 10),
}),
UIStroke = Roact.createElement("UIStroke", {
ApplyStrokeMode = Enum.ApplyStrokeMode.Contextual,
Thickness = 2,
Color = Color3.fromRGB(0, 0, 0),
}),
UIStroke2 = Roact.createElement("UIStroke", {
ApplyStrokeMode = Enum.ApplyStrokeMode.Border,
Thickness = 2,
Color = Color3.fromRGB(255, 255, 255),
}),
}),
})
end
local mountedUI = nil
local mount
function TimerScreen.mountUi(GUI)
if mountedUI then
return
end
mountedUI = true
mount = Roact.mount(Roact.createElement(TimerScreen), GUI, "TimerScreen")
end
function TimerScreen.unMountUi()
if not mountedUI then
return
end
mountedUI = false
Roact.unMount(mount)
end
return TimerScreen
This is what controls it
--[[
@Author Sharafzada
@Description A class meant to interact with the RoundService for each player.
@Version 1.0.1
]]
-- External Services
local RemoteEvents = script.Parent.Parent.RemoteEvents
local Props = require(script.Parent.Parent.Modules.GameProperties)
local _Promise = require(game.ReplicatedStorage.Dependencies.promise)
-- Definitions
local require: any = (require(script.Parent.loader) :: any).load(script)
-- Internal Services
local BaseObject = require("BaseObject")
local Maid = require("Maid")
local Rx = require("Rx")
local Promise = require("Promise")
-- The Class itself
local BaseRoundClass = setmetatable({}, BaseObject)
BaseRoundClass.ClassName = "BaseRoundClass"
BaseRoundClass.__index = BaseRoundClass
function BaseRoundClass.new(RoundService, MetricSerivce, MapService, TeamService)
local self = setmetatable(BaseObject.new(), BaseRoundClass)
-- Dynamic Variables
self._RoundTracker = {}
self._Players = {}
-- Services
self._RoundService = RoundService
self._MetricService = MetricSerivce
self._MapService = MapService
self._TeamService = TeamService
self._Maid = Maid.new()
local close = Rx.fromSignal(game:GetService("Players").PlayerRemoving):Subscribe(function(playerRemoving)
if self._Players[playerRemoving.Name] then
self._Players[playerRemoving.Name] = nil
self._MetricService:RemoveData("PlayerBucket", playerRemoving.Name)
if #self._Players == 0 then
self._MetricService:RemoveBucket("PlayerBucket")
self:Destroy()
end
end
end)
self._Maid:Add(close)
self:Start()
return self
end
function BaseRoundClass:Start()
if #game:GetService("Players"):GetPlayers() >= 2 then
self:NewIntermission():Then(print):Catch(warn)
else
warn("[BaseRoundClass] - Not enough players.")
end
end
function BaseRoundClass:AddPlayer(player)
return Promise.new(function(succ, err)
if self._Players[player.Name] then
err(string.format("[BaseRoundClass] %q is already in the table.", player.Name))
return
end
local data = {
Player = player,
}
if self._RoundTracker["Intermission"] == nil then
if #game:GetService("Players"):GetPlayers() >= 2 then
self:NewIntermission():Then(print):Catch(warn)
else
self:NewIntermission():Then(print):Catch(warn)
err("[BaseRoundClass] - Not enough players.")
end
else
self._MetricService
:ReturnBucket("CombatClass")
:Then(function(d)
RemoteEvents.OnRoundStateUpdate:FireClient(
player,
self._RoundTracker["Intermission"].Time,
"Intermission"
)
for i, v in pairs(d) do
if i == player.Name then
local plr = player.CharacterAdded:Wait()
if plr then
v.CombatClass._OnPlayerStateUpdate:Fire(true, "_InLobby")
end
end
end
end)
:Catch(warn)
end
self._Players[player.Name] = data
self._MetricService:AddToBucket("PlayerBucket", data, player.Name):Then(print):Catch(warn)
succ("[BaseRoundClass] - Player added.")
end)
end
function BaseRoundClass:NewIntermission()
return Promise.new(function(succ, err)
if self._RoundTracker["Intermission"] or self._RoundTracker["Round"] then
err("[BaseRoundClass] - A intermission or round is in progress.")
return
end
self._RoundService
:CreateRound(Props.IntermissionTime, "Intermission", function(d)
self._RoundTracker["Intermission"] = d
RemoteEvents.OnRoundStateUpdate:FireAllClients(self:_ConvertTo24(d.Time), "Intermission")
if d.Time <= 0 then
self._RoundTracker["Intermission"] = nil
task.delay(5, function()
self:NewRound():Then(print):Catch(warn)
end)
self:_SortPlayerIntoTeams():Then(print):Catch(warn)
self._MetricService
:ReturnBucket("CombatClass")
:Then(function(data)
for _, v in pairs(data) do
v.CombatClass._OnPlayerStateUpdate:Fire(false, "_InLobby")
end
print("[BaseRoundClass] - Updated Inlobby variable.")
end)
:Catch(warn)
end
end)
:Then(function()
self._MetricService
:ReturnBucket("CombatClass")
:Then(function(d)
for _, v in pairs(d) do
v.CombatClass._OnPlayerStateUpdate:Fire(true, "_InLobby")
end
succ("[BaseRoundClass] - Intermission created.")
end)
:Catch(warn)
end)
:Catch(function(error)
err(error)
end)
end)
end
function BaseRoundClass:NewRound()
return Promise.new(function(succ, err)
if self._RoundTracker["Intermission"] or self._RoundTracker["Round"] then
err("[BaseRoundClass] - A intermission or round is in progress.")
return
end
self._MetricService
:ReturnBucket("PlayerClass")
:Then(function(da)
self:_PickRandomMap()
:Then(function(map)
print(map)
self._MapName = map.Name
self._MapService
:LoadMap(map.Name, CFrame.new(9.806, 70.468, 363.265))
:Then(function()
game.Workspace.SpawnMap.Lobby.Neutral = false
for _, v in pairs(da) do
v.PlayerClass._OnCharacterLoadRequest:Fire()
end
end)
:Catch(warn)
end)
:Catch(warn)
end)
:Catch(warn)
self._RoundService
:CreateRound(Props.RoundTime, "Round", function(d)
self._RoundTracker["Round"] = d
RemoteEvents.OnRoundStateUpdate:FireAllClients(self:_ConvertTo24(d.Time), "Round in progress")
if d.Time <= 0 then
self._MetricService
:ReturnBucket("PlayerClass")
:Then(function(a)
self._MapService
:UnloadMap(self._MapName)
:Then(function()
self._MapName = nil
game.Workspace.SpawnMap.Lobby.Neutral = true
for _, v in pairs(a) do
v.PlayerClass._OnCharacterLoadRequest:Fire()
end
end)
:Catch(warn)
end)
:Catch(warn)
self._MetricService
:ReturnBucket("CombatClass")
:Then(function(data)
for i, v in pairs(data) do
v.CombatClass._OnPlayerStateUpdate:Fire(true, "_InLobby")
end
print("[BaseRoundClass] - Updated Inlobby variable.")
end)
:Catch(warn)
self._RoundTracker["Round"] = nil
self:_RemovePlayersFromTeams():Then(print):Catch(warn)
self:NewIntermission():Then(print):Catch(warn)
end
end)
:Then(function()
self._MetricService
:ReturnBucket("CombatClass")
:Then(function(d)
for _, v in pairs(d) do
v.CombatClass._OnPlayerStateUpdate:Fire(false, "_InLobby")
end
end)
:Catch(warn)
succ("[BaseRoundClass] - Round created.")
end)
:Catch(function(error)
err(error)
end)
end)
end
function BaseRoundClass:_ConvertTo24(Time)
if Time < 0 then
Time = 0
end
local minutes = math.floor(Time / 60)
local seconds = Time % 60
local formattedMinutes = string.format("%02d", minutes)
local formattedSeconds = string.format("%02d", seconds)
return formattedMinutes .. ":" .. formattedSeconds
end
function BaseRoundClass:_PickRandomMap()
return Promise.new(function(succ, err)
local maps = game.ReplicatedStorage.Shared.Maps:GetChildren()
local sortedTable = {}
for _, v in pairs(maps) do
if v.Name ~= "SpawnMap" then
table.insert(sortedTable, v)
end
end
local randomNumber = math.random(1, #sortedTable)
local loadMap = sortedTable[randomNumber]
if loadMap.Name == "SpawnMap" then
print("[BaseRoundClass] - SpawnMap selected fixing error.")
loadMap = maps[randomNumber - 1]
end
succ(loadMap)
end)
end
function BaseRoundClass:_SortPlayerIntoTeams()
self:_CreateTeams():Then(print):Catch(warn)
return Promise.new(function(succ, err)
local plrs = game:GetService("Players"):GetPlayers()
local shuffledPlayers = {}
for i = #plrs, 1, -1 do
local randomIndex = math.random(1, i)
table.insert(shuffledPlayers, plrs[randomIndex])
table.remove(plrs, randomIndex)
end
local team = 1
for _, player in pairs(shuffledPlayers) do
if team == 1 then
print(player)
self._TeamService:AddPlayer(player, "Red"):Then(print):Catch(warn)
team = 2
else
print(player)
self._TeamService:AddPlayer(player, "Blue"):Then(print):Catch(warn)
team = 1
end
end
succ("[BaseRoundClass] - Teams have been sorted.")
end)
end
function BaseRoundClass:_RemovePlayersFromTeams()
return Promise.new(function(succ, err)
local plrs = game:GetService("Players"):GetPlayers()
for _, player in pairs(plrs) do
if player.Team == "Red" or "Blue" then
self._TeamService:RemovePlayer(player, player.Team.Name)
end
end
self:_DeleteTeams():Then(print):Catch(warn)
succ("[BaseRoundClass] - Teams have been removed.")
end)
end
function BaseRoundClass:_CreateTeams()
return Promise.new(function(succ, err)
self._TeamService:CreateTeam("Red", BrickColor.Red()):Then(print):Catch(err)
self._TeamService:CreateTeam("Blue", BrickColor.Blue()):Then(print):Catch(err)
succ("[BaseRoundClass] - Teams have been created.")
end)
end
function BaseRoundClass:_DeleteTeams()
return Promise.new(function(succ, err)
self._TeamService:DeleteTeam("Red"):Then(print):Catch(err)
self._TeamService:DeleteTeam("Blue"):Then(print):Catch(err)
succ("[BaseRoundClass] - Teams have been removed.")
end)
end
function BaseRoundClass:Destroy()
self._Maid:DoCleaning()
print("[BaseRoundClass] - Destroyed and all cleaned up.")
end
return BaseRoundClass