This script is located in a normal script in workspace.
lua
game.Players.PlayerAdded:connect(function(nP)
nP.Chatted:connect(function(msg)
local gcolor = nP.TeamColor
if gcolor == game.Teams.Host.TeamColor then
if msg == "!bubble" then
game.Players:SetChatStyle(Enum.ChatStyle.Bubble)
elseif msg == "!classic" then
game.Players:SetChatStyle(Enum.ChatStyle.Classic)
elseif msg == "!classicbubble" or "!bothchats" then
game.Players:SetChatStyle(Enum.ChatStyle.ClassicAndBubble)
end
end
end)
end)
Gives this error: The current identity (2) cannot SetChatStyle (lacking permission 1).
Is there a way to fix or get around this error?
The reasoning behind this error is that you cannot use :SetChatStyle()
in a localscript
or a serverscript
Wiki description:
This function sets whether BubbleChat and ClassicChat are being used, and tells TeamChat and Chat what to do using the ChatStyle
enum. Since this item is protected, attempting to use it in a Script
or LocalScript
will cause an error.
This function is used internally when the chat mode is set by the game.
You can only use :SetChatStyle()
in the command bar or use it with plugins to receive no error.
Read more about this here.
If you have any comments or queries, be sure to comment!
Happy scripting!