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
else
--Game stuff
end

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
	else
               map = game.Players.LocalPlayer.CurrentMap.Value
	end
	return map
end

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?

print(‘hi’)
warning(‘ugm nuuu’)
print(‘bye’)

gets:
hi
(orange text) ugm nuuu
bye[/strike]

Nevermind, could have sworn we could use warning()

Are we talking about ServerScripts?

This always works in local scripts for me