So I was following along a tutorial and found myself in a must to use:GetNetworkPing()
.
But it returns 0, for some reason; and this obviously ruins my plans.
How can I fix this?
So I was following along a tutorial and found myself in a must to use:GetNetworkPing()
.
But it returns 0, for some reason; and this obviously ruins my plans.
How can I fix this?
If you are running the script in studio, it will obviously always return 0, since you are not connected to any server but its all running on your computer. So either publish your game and test it on actual roblox game instance, or you can simulate ping in Studio Settings/Network/Incoming Replication Lag
In the replication lag box is a number value. To what number should I change it?
The box represents the number of seconds you want the ping to be. I don’t know what you need to use :GetNetworkPing()
for, so change it according to your needs. Usually though when testing, your game should be playable at atleast 400ms ping to accomodate for players with poor internet connection, including myself lol.
So to make everything clear I am using :GetNetworkPing()
because in the tutorial it teaches of the use of os.time()
and os.clock()
instead of .tick()
. So I am making like a part with a textlabel that shows the CPU time (aka os.clock()
) of a server-side and a client-side. The client-side one can’t be the same obviously because it runs locally. So what I was hoping to do was to sync the time of the server with the client-one accurately. I got the delta time variable but the person who made the tutorial explained that it takes some time for data to get sent from the client to the server and vice-versa. That’s where :GetNetworkPing()
comes in. I don’t need the time for the data to be sent from the client to the server and then back to the client again. So I must simply divide it by 2. But because GetNetworkPing()
prints 0 it messes up all my calculations. So what number do you recommend me to put in the box?
How does it matter which number you put in the box? It will be different for every player that would join, put in whatever you want in a reasonable range and just check if the calculations are correct.
Sorry for late response…
I’ve put 1 in the box and tested the game but it shows the same result.
Did you reset the studio as the notification box told you?
I did, I even put a while true do loop so I can check the :GetNetworkPing()
value. I only got 0s. But later I suddenly got a value of 0.003? How could this happen?
You’re running the :GetNetworkPing()
on a server right?
No, I’m running it in a LocalScript.
Try running it from a server script if it changes anything
I can’t simply run it on a ServerScript
, because :GetNetworkPing()
is meant to run on the LocalPlayer
.
I am pretty sure it isnt, you can run it from a server script on any player
I tried testing my scripts once again and turned out to be working like I wanted in the first time. Everything synced and to it’s place.
The wiki says the same thing. But overall like you said, because I was running :GetNetworkPing()
locally it didn’t give me the results I wanted in the first time. But out of nowhere maybe with the value changed in the box mentioned above it probably fixed some stuff. Anyway, thanks!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.