Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with Chatted event, not printing?

Asked by
FiredDusk 1466 Moderation Voter
8 years ago

Not printing "A" when Player1 says "kill" or "Kill". Thanks for helping!

game.Players.PlayerAdded:connect (function(player)
    if player.Name == "Player1" then
        player.Chatted:connect (function(msg)
            if msg:lower() == "Kill" then
                print"A"
            end
        end)
    end 
end)

1 answer

Log in to vote
3
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
8 years ago

msg:lower() converts all the characters to lower case, but you are comparing it to a string with an uppercase letter (the 'K' at the beginning). Therefore, the condition will never return true.

if msg:lower() == "kill" then
    print("A")
end
Ad

Answer this question