local prefix = "!"

function playerMsg(plr,mesg,sm) -- sets function, plr being the sender, mesg being the message, and sm being whether it's a system message local players = game.Players:GetChildren() -- gets all the players for _,v in pairs (players) do -- does the following for every player local find = v.StarterGui:FindFirstChild("GUI_NAME") -- finds the gui if find then -- if the gui exists if sm == false then find.Announce.Frame.MSG.Text = mesg -- changes the text find.Announce.Frame.Type.Text = "Message" -- changes the type find.Announce.Frame.By.Text = plr.Name -- sets the text to sender's name elseif sm == true then find.Announce.Frame.MSG.Text = mesg find.Announce.Frame.Type.Text = "System Message" find.Announce.Frame.By.Text = "System Message" end end end end

game.Players.PlayerAdded:connect(unction(p) -- when a player joins p.Chatted:connect(function(msg,recipient) -- when a player talks, msg is the text, and recipient is whoever the msg is whispered to (nil if not a whisper) if msg:sub(1,prefix:len()+3) == prefix.. "m " and p:GetRankInGroup(2679030) >= 9 then -- checks to see if the first part is the prefix and 'm' print(p.Name.. " sent a message!") -- prints playerMsg(p,msg:sub(prefix:len() + 3),false) -- calls function elseif msg:sub(1,prefix:len()+4) == prefix.. "sm " and p:GetRankInGroup(2679030) >= 9 then -- you only need one 'then' playerMsg(p,msg:sub(prefix:len() + 4),true) end end) end

3 comments

1

Could you put the code into Block Format?

0

local prefix = "!" function playerMsg(plr,mesg,sm) -- sets function, plr being the sender, mesg being the message, and sm being whether it's a system message local players = game.Players:GetChildren() -- gets all the players for _,v in pairs (players) do -- does the following for every player local find = v.StarterGui:FindFirstChild("Announce") -- finds the gui if

0

still not in a codeblock?