This activated even if I were to say for example "g"
function Chatted(msg)
if msg:sub(1,3) == "God" and player.Name == "Polendris" or player.Name == "Player" then
--private code here
end
end
player.Chatted:connect(Chatted)
This activated even if I were to say for example "g"
function Chatted(msg)
if msg:sub(1,3) == "God" and player.Name == "Polendris" or player.Name == "Player" then
--private code here
end
end
player.Chatted:connect(Chatted)
The if statement is a and b or c and because of the boolean order of operations, this is interpreted as (a and b) or c and since c is true, the statement is true regardless of a and b. Use parentheses to solve this.
This discussion is preserved as it was. New answers, comments, and votes are closed.
4 comments
The problem is that you have an or operator in your if statement. If player's name is "Player", it will run no matter what. Add a parenthesis, like this: if msg:sub(1,3) == "God" and (player.Name == "Polendris" or player.Name == "Player")
Alright thanks. It worked :)
Add [SOLVED] or something to your question so people don't get misdirected.
Crap, he hid his private code. How are we going to steal his trade secrets now?