player:GetNetworkPing() returns IncomingReplicationLag when called in-studio

the motive:

cc @GroupyClumpy

the request:

player:GetNetworkPing(), when called in-studio, returns the value stored at IncomingReplicationLag (instead of returning 0)

or

player:GetNetworkPing(): number
player:GetNetworkPing(useStudioIncomingReplicationLag: boolean?): number
takes an optional boolean that’s only respected when called in-studio:

player:GetNetworkPing(true)
--- ... when in-studio, reads & returns `Settings.IncomingReplicationLag`
--- ... otherwise, returns `player:GetNetworkPing()`

obviously useStudioIncomingReplicationLag is long and i’m sure that a smaller, more concise name can be cooked up

the yapping:

the code gymnastics required to simulate what player:GetNetworkPing() would return in-studio shouldn’t exist

here i am requesting a behavior change or addition to the vanilla player:GetNetworkPing() method that would allow network latency to be read properly when called in studio. it would satisfy cases such as:

--- because player:GetNetworkPing() doesn't read IncomingReplicationLag, 
--- simulate 200ms latency
--- the value passed into this function has to be changed *every time* IncomingReplicationLag is changed :/
--- as there is no way to read that setting using the roblox game api
--- if this function had a smell it would stink up the entire calling environment

--- returns latency \
--- pass `studiolatency` to account for studio sessions not reading IncomingReplicationLag
local function readlatency(player: Player, studiolatency: number?): number
	return RunService:IsStudio() and (studiolatency or 0) or player:GetNetworkPing()
end

… or cases where developers still use a ping-pong remote to measure remote latency

11 Likes

Or make GetNetworkPing() just return the value defined in IncomingReplicationLag when in Studio, there is no need for passing an argument, this can just be handled internally

yes this was one of the two things that i proposed in this feature request

I would definitely not want to have to go into my scripts and change arguments (even though I wouldn’t have to change it later). I suggest to make it a setting in studio settings.

I mean you can still just edit 1 script, copy it and remove the others by bulk-selecting them and paste the modified script in their places