I’m trying to create a LocalScript that checks if someone in the server sends a chat message in the game. This is not possible with game.Players:PlayerAdded, so is there any other method to check if a message is sent in the chat.
(P.S: I’m not trying to use any RemoteEvents or RemoteFunctions)
You can just loop through all of the current players.
game.Players.PlayerAdded:Connect(function(player)
--code here
print(player.Name)
end)
wait(1)
for i, player in pairs(game.Players:GetChildren()) do
--code here
print(player.Name)
end
It’s not exacly what I’m trying to achieve, what I’m trying to do is when anyone in the game chats a function gets activated. I’m not sure if it’s possible though…
local function ONChat()
print("Player Chatted")
end
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(OnChat)
print(player.Name)
end)
wait(1)
for i, player in pairs(game.Players:GetChildren()) do
player.Chatted:Connect(OnChat)
print(player.Name)
end