-
What do you want to achieve? In studio, when the game starts it hits a lag spike as to load in elements. In game however, the lag spike doesn’t happen and the game doesn’t have time to load things in, and the player is able to move around and skip triggers. I wanted to add a GUI to show up and pause the player when the game starts.
-
What is the issue? I have no idea how to do this, and I can’t find anything that relates to my problem online.
-
What solutions have you tried so far? Cannot find any solutions anywhere.
Have a UI element inside StarterGui that is enabled by default. When a player loads in, it’ll be the first thing that they see.
As for “pausing the player”, I’m assuming that you mean making them unable to move. To do that, you can set the WalkSpeed and JumpPower of the player’s character to 0.
Wiki Articles:
I couldn’t understand what you wanted.
Do you want a your own loading screen and not the default loading screen by roblox?
Hey there!
You could create a GUI and make it show up as soon as a player joins.
Steps to make a simple Opening GUI:
- Create a GUI that you’d like to show up while a player is loading
- Insert a
LocalScript
intoReplicatedFirst
and add the following code:
game.ReplicatedFirst:RemoveDefaultLoadingScreen()
local interface = script:WaitForChild("Replace_With_GUI_Name")
local Players = game:GetService("Players")
local ContentProvider = game:GetService("ContentProvider")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
interface.Parent = playerGui
repeat wait() until ContentProvider.RequestQueueSize < 1
--[[
You can add whatever code you'd like here. For example, a nice animation
to get rid of the UI, just make it disappear with interface.Enabled = false,
whatever you'd like.
--]]
script:Destroy() --Keep this so that the UI does not show up anymore.
- Insert the UI you created into the script.
And that’s it!
It’s really simple and I only sent template code as copying code is not good practice.
Now that you’re using ContentProvider, you should study it and check out what other things you can do with it. It’s a very useful tool.
What does the one in repeat wait() until ContentProvider.RequestQueueSize < 1 signify?
That waits until there are less than one asset to load.
I see! Works pretty good, not how i envisioned it, but it still works! Thanks!
I thought it was more reliable to use the Game:IsLoaded bool? I thought RequestQueueSize can be unpredictable because of what the server has passed onto the client can be inconsistent with how much still needs to be loaded.
That’s true, I only use RequestQueueSize
because from my experience, it usually waited longer than game:IsLoaded()
.
The main gain I see in using Game:IsLoaded is you don’t need to use a repeat loop for it to work. I see this as a cleaner way to write code.
if not game:IsLoaded then
game.Loaded:Wait()
end
Glad it works. If you have any further questions, feel free to message me.
Now that it’s solved, you should either write [SOLVED] in the title or mark one of the replies as the solution.
A bunch of people look at unsolved support requests.
Honestly, it doesn’t really matter what you use. A person can use either one and get almost the exact same results.
Yes, it’s just something I learned from a post that I always see circling around saying why not to use wait()
. Ever method works fine in most senarios.
Yes, it is best to avoid using wait()
. But in this case, it isn’t a problem. This script only runs once, when you join.