My game works in studio but not roblox?

My game works in studio but not the actual game once published. Wasn’t to sure if I was suppose to put this in bugs or scripting support but I’m here now.

Studio:

Roblox:

Is this a simple issue or is it something that run’s deeper within my game or can I just pass it off as something that’ll work it’s self out :thinking:

1 Like

What parts dont work? I can tell the sound doesnt, and thats likely because you lack the permissions to use it. As far as I know, you need to upload your own sound file and use that.

Your round timers at the top clearly dont work either. This is almost certainly client-sided code, but I cant tell what the issue would be without seeing the code. It could be because you used something.child instead of something:WaitForChild("child"). From my experience, studio tends to load faster than regular roblox, so WaitForChild is almost necessary. You may also try putting the UI in ReplicatedFirst and put a script to parent it to PlayerGui to see if that fixes it.

Your client is also using significantly less memory in roblox than studio. Im not very educated on how memory works in roblox, but it could mean that even more stuff isnt loading. It could also mean that some of your more complicated classes arent being instantiated properly.

Send your code for the timers at the top of the screen and the hierarchies and ill see if i spot anything

1 Like

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

I’m not to sure but I did hear somewhere that roblox studio tends to take up some more memory as opposed to roblox but I could also be wrong and it can be something else.

just as @Verse_NOVA said, you should try using :WaitForChild() because studio loads faster than roblox as in studio your own computer simulates the client & server while in roblox your computer has to actuall communicate with roblox servers, which takes significantly longer

The code seems fine from a quick look. I did forget to mention one more potential issue. If you forgot to publish your game to roblox after making changes, then that could be why it isnt working. If you already fixed that loading bug in studio (if it happened) then all you would need to do is publish to roblox.

Other than that, using WaitForChild is your best bet

I have published the game of course and I am slowly starting to implement WaitForChild instead of .something

I have went ahead and added WaitForChild in every script but the issue still persists surprisingly which is confusing.

Everything is loading properly but services such as the SoundService, and UI such as the ShopUI don’t work and possibly more. However, all the services do log a starting message which also is super confusing.

do you own all of the assets that you are using? for example, sounds sometimes have issues if you dont own them.

I do have the game under the group with sounds in it however some sounds which are not under the group i do not knlw there ids at the time also dont work the only id i have is for the lpbvy music 138375283701084

I am still experiencing this issue I have added a lot more WaitForChild and I have updated my sound code

RemoteEvents.OnSoundPlayRequest.OnClientEvent:Connect(function(SoundId, Volume, Parent, Looped)
	local sound = Instance.new("Sound")
	sound.SoundId = SoundId
	sound.Volume = Volume
	sound.Parent = Parent
	sound.Looped = Looped

	if sound.Loaded then
		if sound.Looped then
			if sound.Parent then
				sound:Play()
				return
			else
				SoundService:PlayLocalSound(sound)
				return
			end
		else
			sound.Ended:Connect(function()
				sound:Destroy()
			end)
			if sound.Parent then
				sound:Play()
				return
			else
				SoundService:PlayLocalSound(sound)
				return
			end
		end
	end
end)