Hi, I wanna make a loading screen that loads according to the client’s Internet connection. I don’t know how I can achieve this goal. Help is appreciated!
That’s going to have to make more sense, “according to the client’s Internet connection” isn’t very descriptive.
I mean, according to the client’s internet connection’s speed. My bad
I think lag testers exist, you could try to base it off of that (maybe?)
I would fire a remote event with tick()
and compare to the time of receiving, and that’d be your time difference: the internet speed.
Not sure if this is what you mean, but I suggest waiting until the game is loaded to end your loading screen. For example, if you created a loading screen using a ScreenGui, you would first play the loading screen, then destroy it after the game has been loaded for the client. Like this:
local loadingScreen = game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("ScreenGui") -- path to loading screen
-- code here to play the loading screen (or however you want to display it)
wait(2) -- minimum # of seconds that the loading screen will appear for before checking if the game is loaded
if not game:IsLoaded() then
game.Loaded:Wait() -- if the game isn't loaded yet, it will wait
end
loadingScreen:Destroy() -- destroys the loading screen after the game has been fully loaded
(This would be a LocalScript inside of ReplicatedFirst, but if you are going to use it elsewhere, then put the LocalScript in ReplicatedStorage).
What do you mean by time of receiving?
Here’s what I mean:
Server:
remoteEvent:FireClient(player, time())
Client:
remoteEvent.OnClientEvent:Connect(function(serverTime)
-- timeDiff is the amount of seconds it takes for a packet to deliver theoretically.
local timeDiff = time() - serverTime
end)
I used game.Loaded:Wait()
but it didn’t print what I was printing to check
If you want some background information on loading screens, you’re probably going to want to read this Developer Hub article. I’m sure it’ll help you out.
Okay, hold on, I will try this
I don’t really understand the main question, but what I’m guessing is that you could use tick()
to compare the time of when you started loading to the time of where you finished loading.
Here’s an example if you need it though.
-- This would be a LocalScript in replicated first, so that the loading times are accurate.
-- In ReplicatedFirst, the script will always load first, as you should take the service for it's name. Everything in here replicates first.
local StartingTick = tick()
game.Loaded:Connect(function()
local EndingTick = tick()
print("Loading Time in Seconds:",EndingTick - StartingTick)
end)
Hope this helps you.
On OnClientEvent the ServerTime will be the player argument u sent so it should be Player, ServerTime