My script detects if somebody said walter and prints their name.Later i'm going to teleport to them but for now its print.
1 | for i,currentPlayersChatting in pairs (game:GetService( "Players" ):GetPlayers()) do |
2 | currentPlayersChatting.Chatted:connect( function (speaker, msg) |
3 | if string.lower(msg) = = "walter" then |
4 | print (speaker.Name) |
5 | end |
6 | end ) |
7 | 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:
1 | for i,currentPlayersChatting in pairs (game:GetService( "Players" ):GetPlayers()) do |
2 | currentPlayersChatting.Chatted:Connect( function (msg) |
3 | if string.lower(msg) = = "walter" then |
4 | print (currentPlayersChatting.Name) |
5 | end |
6 | end ) |
7 | end |
Also, keep in mind how .Chatted works is like this:
PlayerInstance.Chatted
.