I have enabled HTTP requests via the Game Settings. I was trying to add the Google Analytics code as described in the WIki. I added this to a Script in ServerScriptService:
local GA = require(153590792)
GA.Init("UA-1234567-8")
But when I try the game locally in Play mode, I get this error:
17:13:46.122 - Model.MainModule:100: Init() can only be called from game server
17:13:46.122 - Stack Begin
17:13:46.123 - Script ‘Model.MainModule’, Line 100 - field Init
Question: Is there anyway that I can get this working when testing a game locally in Play mode?
Due to the way play solo works currently, it doesn’t distinguish well between the server and client. It’s being worked on long-term, but I have no idea when the issue will be fixed.
Until then you just have to check for LocalPlayer (which seems to be the only reliable way to see if play solo is running in a server script) and not run any server-sided code that will break on the client.
If you want to modify the script to retain it’s anti client execution AND work in play solo, you will have to check if RunService IsClient and IsStudio are both true to give it a green light in case of play solo.