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

.Chatted not working as intended?

Asked by 3 years ago

I have a script that uses player chatted to set a players class, here's a base of what I want the script to look like:

game.Players.PlayerAdded:Connect(function(plr)
    plr.Chatted:Connect(function(msg)
        if msg == "here" then
            print("lol")
        elseif msg == "here2" then
            print("lol1")
        end
    end)
end)

If I say here it works, but if I say here2 it doesn't, how would I get around this (without changing the message)

1 answer

Log in to vote
0
Answered by
jundell 106
3 years ago
Edited 3 years ago

I recommend using Players.PlayerChatted to do this.

local example = “test”
if msg:sub(1, example:len()) == example then
    print(“message starts with “ .. example)
end
0
Apologies for the wrong unicode quotes, I’m currently on mobile. jundell 106 — 3y
0
Thank you! kegirosou 17 — 3y
0
If I solved your problem, please mark this as the solution :) jundell 106 — 3y
Ad

Answer this question