So, im making a admin script for logging the chat of a certain user, but for some reason its giving a strange error on chatted event, can anyone help fix it? its a local script btw
The Line with the error
game.Players[_G.SelectedPlayer].Chatted:Connect(function(message, recipient)
Katrist
(Katrist)
July 28, 2022, 8:00pm
2
Could you send the whole code? I don’t know what could be wrong with this one line.
Alright, here is it:
local toggled = true
game.Players[_G.SelectedPlayer].Chatted:Connect(function(message, recipient)
if not toggled then return end
print(msg)
end)
For now its just a simple print thing for testing
Katrist
(Katrist)
July 28, 2022, 8:06pm
4
It’s because you did:
print(msg)
Instead of:
print(message)
New code:
local toggled = true
game.Players[_G.SelectedPlayer].Chatted:Connect(function(message, recipient)
if not toggled then return end
print(message)
end)
I changed that but the error in the 3rd line continues, its the same error: Invalid Argument #2 (string expected, got nil)
Katrist
(Katrist)
July 28, 2022, 8:08pm
6
Is _G.SelectedPlayer a string that you set earlier?
1 Like
Yeah it is, its set to my name just for testing
Oh nevermind i found out the error was at a extra line before it i forgot to delete, thanks for the help tho!