What I’m attempting to achieve is when a player who has a name of someone on the admin list, it will allow the code to run through if the message of DDD is typed by an admin.
So like this, if a player is an admin and they say “DDD” then the Event will fire.
I’ve looked at the Chatted page on the ROBLOX Wiki/Developer Page and I’ve tried looking on the devforum and I have no idea why this isn’t working. I feel like it’s something simplistic and I just keep missing it.
I don’t know what the error is so I haven’t been able to do much edits. I’ve tried changing the admin value but nothing happens, i’ve tried a for pair, nothing unless I did it wrong. I’ve tried rewording it and it did nothing. The script is below, thank you for any help you can give me. Also yes the event does work as I have it programmed to a GUI Button.
--Made By MillerrIAm
-----------Variables-----------
Event = game.ReplicatedStorage.Extras.BellEvent
plr = game.Players
----------- Messages -----------
msg1 = "DDD"
msg2 = "Ring the bell."
----------- Admins -----------
admins = {["MillerrIAm"] = true; ["NemesisY2J"] = true; ["Sonicxman"] = true;["Dewwy5280"] = true}
-----------Main Code-----------
plr.LocalPlayer.Chatted:Connect(function(plr,msg)
if admins[plr.Name] then
if msg == msg1 then
Event:FireServer("Ring the bell!")
end
end
end)
Im fairly certain you can check if the player is a admin when they join server-side, then hook a .Chatted Event to the player, and then you don’t have to fire remotes.
Oh okay so my goal is for when a message is sent, it fires an event as it controls a GUI Tween. That’s why I have it firing an event. If you have a discord, I can show you what i’m attempting to do. On-top of that, you are right… you can check to see if a player is an admin through a server script I just never really tested it as I had other goals but I’ll look into that. I still would like to ask if you could give me a little help with my main issue, I am VERY NEW to chat commands and such. What it does is if an admin says msg1 then it fires the event that controls the GUI. The Event works perfectly fine, same with the script, how I know is i have it programmed with a button but I want to control it with a chat message instead.
oh thank you! I wish I would of known that two months ago lol, that would of helped me incredibly although i will continue to use my version unless I can do something different inside of a ServerScript.
plr.LocalPlayer.Chatted:Connect(function(plr,msg)
if table.find(admins, plr.Name) then
if msg == msg1 then
Event:FireServer("Ring the bell!")
end
end
end)
Oh, by the way, you’re calling the value plr when you’re doing localplayer. Msg is returned nil due to plr being the message. Instead, change it to:
Since no one here has really fixed OP’s issue, here is what you need to do.
plr.LocalPlayer.Chatted:Connect(function(plr,msg)
This code is incorrect. The Chatted callback will only provide the msg as you already know what player you are trying to detect the chat from: plr.LocalPlayer
After you fix that part plr.Name will be invalid. This is because it will index game.Players.Name which is not what you want. You want to instead change it to game.Players.LocalPlayer.Name. With your code, you can use plr.LocalPlayer.Name.
After doing these 2 fixes, your code will run fine.
I just meant that the variable named msg1 is set to DDD and the if msg == msg1 implies that msg1 contains “Ring the bell”.
Sorry if I confused you.
Not important just a mention.