while true do wait (0.1) prefix = "!"
if message:sub(1,3) == prefix.."m " and player:GetRankInGroup(2679030) >= 9 then print "Hello world I sent a message" then game.StarterGui.Announce.Visible= true then game.StarterGui.Announce.Frame.MSG.Text= "(message:sub)" then game.StarterGui.Announce.Frame.Type= "Message" game.StarterGui.Announce.Frame.By= ("player.Name)" elseif if message:sub(1,3) == prefix.."sm " and player:GetRankInGroup(2679030) >= 9 then print "Hello world I sent a message" then game.StarterGui.Announce.Visible= true game.StarterGui.Announce.Frame.MSG.Text= "(message:sub)" then game.StarterGui.Announce.Frame.Type.Text= "System Message" then game.StarterGui.Announce.Frame.By= "System" end end
You've done almost everything wrong. I will re-write your script with some explanations:
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
Closed as Not Constructive by 1waffle1, TheDeadlyPanther, and Shawnyg
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?