Detecting Server or client

What I want to achieve

I want to be able to detect if a log is comming from the server or the client. I want to be able to detect this from a server script in ServerScriptService.

Example

local LogService = game:GetService("LogService")
local DataStoreService = game:GetService("DataStoreService")

LogService.MessageOut:Connect(function(msg, typ)
	if msg:IsFromClient() then
		print("msg: "..msg)
		print("typ: "..tostring(typ))
	end
end)

To check if something is being ran on client or server then use RunService it has IsClient() and IsServer() methods (or something similar to those names, look it up)

1 Like

server prints usually don’t replicate unless you are a dev of the game, do messageout in a localscript if you want to catch client errors and do messageout in a serverscript if you want to catch server errors

I have looked it up, it didn’t work which is why I made this post. This is what I tried:

local LogService = game:GetService("LogService")
local DataStoreService = game:GetService("DataStoreService")
local RunService = game:GetService("RunService")

LogService.MessageOut:Connect(function(msg, typ)
	if RunService:IsClient() then
		print("msg: "..msg)
		print("typ: "..tostring(typ))
	end
end)

A server script cathes both logs from the client and the server, and I want to keep it all in a server script.

I tried it in studio and it caught the log from the client, but in an actual published game, it doesn’t

my game is published, and it logs both client and server sided messages