Saw your comment, thank god I saw it cause I was figuring out why the script is not working lol, thx for telling that.
bruh why so many youtube tutorials make this complicated?!1
This is the best tutorial ive ever read
Is this correct:
game:GetService(“TextChatService”).OnIncomingMessage = function(msg: TextChatMessage)
local p = Instance.new(“TextChatMessageProperties”)
local player = game.Players:GetPlayerByUserId(msg.TextSource)
if player.UserId == 7719976151 then
p.PrefixText = "<font color = '#0000ff'>[OWNER]</font>: "..msg.PrefixText
elseif player:IsInGroup(35622691) then
p.PrefixText = "<font color = '#0000ff'>[FAN]</font>: "..msg.PrefixText
end
return p
end
If the message was sent by the system (e.g., “Your friend has joined you”), the player object will be nil
:
In this case, player.UserId
will result in an error. Therefore, the system message won’t be shown, as the function execution is halted and nothing is returned. As for the player message, it should work as expected.
To check if the message is from the system, you can simply check if msg.TextSource
is nil
. If it’s nil
, return p
without modifying it.
As for player:IsInGroup(35622691)
, I’m pretty sure this will involve a roundtrip to the Roblox server. So, instead of checking it multiple times for each messages, check it once and store it in a variable.
My bad, I didn’t notice this before. msg.TextSource
is an object, so you need to get the UserId
property from it: msg.TextSource.UserId
.
And I would put that in a server script? because when I did msg.TextSource.UserId
I think it either showed me an error or it showed the chat tag but not the desired one when i did it in a local script
At least read the text properly…
srry, I misunderstood that response ill fix the code and see if it works