Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

There is an error in the Chat Message script? Gives error saying it lacks permission?

This script is located in a normal script in workspace.

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?

1 comment

0

You can't use :SetChatStyle() in a localscript or a serverscript.

1 answer

✓ Accepted answer

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 ChatStyleenum. 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!

This discussion is preserved as it was. New answers, comments, and votes are closed.