On studio my game works 100% of the time without any errors in terms of this issue but whenever I join the game on the actual roblox client it doesn’t load at all.
Like 90% of the time the player spawns in an empty world, and in the rare 10% when the game actually works it SHOULD, the player character is supposed to move to server storage, the camera type to scriptable, and the player gui should show up and start the game.
I know about players loading before the game fully loads but I feel that no matter what I do the game just doesn’t load. I’m not even sure what part of the game is the issue here ngl so I don’t have any code to show at the moment but if you want any just lmk
Instead of implementing a simple task.wait like the player above me you can make the script yield till the character loads by doing game.Players.LocalPlayer.CharacterAdded:Wait() also if your camera script is on the client then immediately trying to change its property wont work. The camera takes time to load usually a couple seconds but it depends.
Turns out the code I was trying to attempt the loading function in a renderstepped loop was being overshadowed by another renderstepped loop LOL
Here’s my code now (thanks for the charadded:wait() idea btw)
local loaded = false
local function load(char)
ReplicatedStorage.LoadPlayer:FireServer()
while camera == nil do
camera = game.Workspace.CurrentCamera
end
camera.CameraType = Enum.CameraType.Scriptable
x,y,z = 0,7,-10
camera.CFrame = CFrame.lookAt(Vector3.new(x, y, z), Vector3.new(x, y-7, z+12))
player.PlayerGui.Game.InfoScreen.Visible = false
player.PlayerGui.Game.Screen.Visible = true
player.PlayerGui.Game.BackButton.Visible = false
player.PlayerGui.Game.SubmissionScreen.Visible = false
loaded = true
end
while RunService.RenderStepped:Wait() do
if not loaded then
local char = player.Character or player.CharacterAdded:Wait()
load(char)
else
-- other code
end
end