Throw a warning when trying to access Players.LocalPlayer while a NetworkServer exists

Since the localplayer should never be expected to exist on a server, any attempt to query the value should be considered a mistake.

But it does throw an error?

“LocalPlayer not a valid member of Players”

No it doesn’t

print(game.Players.LocalPlayer) --> nil

This would break a few debugs for me

I agree with GollyGreg.
People use code like so:

if game.Players.LocalPlayer then
--Play Solo stuff
--Game stuff

I thought everyone used

if game:FindService'NetworkServer' then -- Server stuff end if game:FindService'NetworkClient' then -- Client stuff end

Oh well

You get an error in online mode when you try to modify a local player and it’s nil, so I don’t see why you would need a warning for it when you’re already getting an error. I use the same code FLU posted below to test if something is in solo or not.

I didn’t explain properly. I’m talking about accessing the property Players.LocalPlayer, as in v=Players.LocalPlayer. Not actually doing something with the player.

Then that cracks me up lol.

Apparently not you :stuck_out_tongue:

If this was done, wouldn’t it break this code here that I use?

Module.GetMap = function()
	local map
	if game.Players.LocalPlayer == nil then
		map = workspace.Game.CurrentMap.Value
               map = game.Players.LocalPlayer.CurrentMap.Value
	return map

I don’t see why the value cannot continue to return nil and just throw a warning at the same time?

[strike]You guys do know that a warning is different from an error right?

warning(‘ugm nuuu’)

(orange text) ugm nuuu

Nevermind, could have sworn we could use warning()

Are we talking about ServerScripts?

This always works in local scripts for me