I believe the problem may lie in the fact that the function is never called, or that it is embedded in a ChildAdded function, meaning it would only work in the instant that someone joined the game. I may just be overlooking this, but I'm exhausted.
p = {"player1","player2","player3"} game.Players.ChildAdded:connect(function(newPlayer) if (newPlayer.Name ~= p) then return end newPlayer.Chatted:connect(function(msg) msg = msg:lower() if (msg == ":rend") then game.Workspace.Terminal.SoundWin:Play() local m = Instance.new("Message", game.Workspace) m.Text = ":// TCD HAS SUCCESSFULLY REPELLED THE INSURGENT THREAT. // RAID ID: "..math.floor(tick()) wait(10) m:Destroy() end end) end)
On line 4, you're comparing the player's name to the table (p
) itself; instead, I recommend using a dictionary and checking whether a player's in the list that way. An example of this would be:
local PlyrNamesInTable = {['TheeDeathCaster'] = true} -- An example of a dictionary; 'TheeDeathCaster' being the index, and 'true' being the value. ... if PlyrNamesInTable[Player.Name] then -- We're checking whether the player's name matches (or finds(?) an index in the table; if not, it'll return `nil`, and if so, it'll return `true`. print(Player.Name..'\'s an admin.') -- If a player's an admin, it's print `PLAYER_NAME's an admin.` end
Stuff Touched On But Never Really Explained
Dictionaries
- To quote the dev hub, "a dictionary stores a set of key/value pairs." In other words (please correct me if need be), we can set an index and a value in the table, like in the above code. (For more info, I recommend checking out the link.)If you have any questions, please let me know. Have a good day. :)
Try
game.Players.PlayerAdded:Connect(function(newPlayer)