Chat local output

i made this for personal use but maybe it could help y’all too

it basically just shows LOCAL output messages in chat, without needing to have the output window open too
image
image
image

i bascially just made it to learn setcore & logservice

code
local Enabled = true


--// code
local logService = game:GetService("LogService")

local variables = {
	["error"] = {
		color = Color3.fromRGB(255, 57, 57);
		prefix = "[ERROR]";
	},
	["warning"] = {
		color = Color3.fromRGB(252, 255, 52);
		prefix = "[WARNING]";
	},
	["output"] = {
		color = Color3.fromRGB(255, 255, 255),
		prefix = "[PRINT]"
	}
	
}

logService.MessageOut:Connect(function(Message, MsgType)
	if not Enabled then return false end
	
	local color
	local prefix
	local client = true
	
	if MsgType == Enum.MessageType.MessageError then
		color = variables.error.color
		prefix = variables.error.prefix
	elseif MsgType == Enum.MessageType.MessageWarning then
		color = variables.warning.color
		prefix = variables.warning.prefix
	elseif MsgType == Enum.MessageType.MessageOutput then
		color = variables.output.color
		prefix = variables.output.prefix
	else
		color = Color3.fromRGB(119, 29, 255)
		prefix = "[ROBLOX]"
	end
	
	game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", {
		Text = prefix.." [CLIENT] "..Message;
		Color = color;
		Font = Enum.Font.SourceSansBold;
		TextSize = 18
	})
end)
16 Likes

LOL. That’s incredibly smart. I never thought to do that.

The only problem, is that you need to make sure that this only appears in the Studio, and not in the actual game.

2 Likes

Yeah this can be easily added by adding if not game:GetService("RunService"):IsStudio() then return false end under if not Enabled then return false end in the MessageOut function.

logService.MessageOut:Connect(function(Message, MsgType)
	if not Enabled then return false end
	if not game:GetService("RunService"):IsStudio() then return false end	
. . . 
end)
2 Likes

Great. That’s good. It would be pretty awkward if the users playing the game would see the script output and errors XD.

1 Like

Whoa, this is incredibly big brain. I’ve legitimately never thought about doing something like this. I’ll definitely be using this for my current and future projects. Great work! :smiley:

3 Likes

I can’t test this right now. Does this work in game? Just wondering :grin:

Why not just stick to the default output widget? It works just fine

Yeah, if you don’t want it to work in game simply add if not game:GetService("RunService"):IsStudio() then return false end in the function

Yes, the output widget is very good, however I simply just made for personal use and posted it here incase anyone wanted to use it. I originally created it for myself to learn about setcore

I remember Log Service wouldn’t work online.

It does work, some games ban users if a script parented to nil errors or outputs anything

Is there a way to make this for people with TC access only? (If that makes sense)

Because I don’t want this to appear for everyone and I want it only for devs of the game.

Sure!

As far as I’m aware, there’s no way a script can check if a player has TC access, however, you can tell the script.

At the top of the script make a table with all your developer’s UIDs.
Like this:

local DeveloperIDs = {
	130154242, --// watameln
	0, --// Developer 2
	0, --// Developer 3,
	-- ect..
}

Then, when the MessageOut function is ran, check if the local player’s UID is in that table, like this:

table.find(DeveloperIDs, game.Players.LocalPlayer.UserId)

If that returns false, it means their not a developer, and you can return false to end the function.

Hope this helped!

Full Code
local Enabled = true

local DeveloperIDs = {
	130154242, --// watameln
	0, --// Developer 2
	0, --// Developer 3,
	-- ect..
}


--// code
local logService = game:GetService("LogService")

local variables = {
	["error"] = {
		color = Color3.fromRGB(255, 57, 57);
		prefix = "[ERROR]";
	},
	["warning"] = {
		color = Color3.fromRGB(252, 255, 52);
		prefix = "[WARNING]";
	},
	["output"] = {
		color = Color3.fromRGB(255, 255, 255),
		prefix = "[PRINT]"
	}

}

logService.MessageOut:Connect(function(Message, MsgType)
	if not Enabled then return false end
	if not table.find(DeveloperIDs, game.Players.LocalPlayer.UserId) then return false end

	local color
	local prefix
	local client = true

	if MsgType == Enum.MessageType.MessageError then
		color = variables.error.color
		prefix = variables.error.prefix
	elseif MsgType == Enum.MessageType.MessageWarning then
		color = variables.warning.color
		prefix = variables.warning.prefix
	elseif MsgType == Enum.MessageType.MessageOutput then
		color = variables.output.color
		prefix = variables.output.prefix
	else
		color = Color3.fromRGB(119, 29, 255)
		prefix = "[ROBLOX]"
	end

	game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", {
		Text = prefix.." [CLIENT] "..Message;
		Color = color;
		Font = Enum.Font.SourceSansBold;
		TextSize = 18
	})
end)

EDIT: I messed up the table.find, I’ve fixed it.

2 Likes