My script detects if somebody said walter and prints their name.Later i'm going to teleport to them but for now its print.
for i,currentPlayersChatting in pairs(game:GetService("Players"):GetPlayers()) do currentPlayersChatting.Chatted:connect(function(speaker, msg) if string.lower(msg) == "walter" then print(speaker.Name) end end) end
The problem is that .Chatted
does not have speaker
and message
. It only has message
.
Read more about it here
Your fixed script would be:
for i,currentPlayersChatting in pairs(game:GetService("Players"):GetPlayers()) do currentPlayersChatting.Chatted:Connect(function(msg) if string.lower(msg) == "walter" then print(currentPlayersChatting.Name) end end) end
Also, keep in mind how .Chatted works is like this:
PlayerInstance.Chatted
.