function onChatted(msg, recipient, speaker) local source = string.lower(speaker.Name) msg = string.lower(msg) if msg then print(speaker.Name.. msg) end end function onPlayerEntered(Player) Player.Chatted:Connect(function(msg, recipient) onChatted(msg, recipient, Player) end) end onPlayerEntered()
The script will go like this: First, the Player will talk. Second, it should print the username and the message. Example: raid6n: Can you be my friend?
The script doesn't work with an output of: 18:07:59.288 - ServerScriptService.Script:11: attempt to index local 'Player' (a nil value)
I don't know why it doesnt work as I defined what "Player" is in line 9
I'm not good at this, so please send an answer if you can. This is a regular script.
thats hard maybe a local script and use local Player = game.Players.LocalPlayer
it maybe work try putting at line 10
Line 16. If you don't a value in an argument of an executed function, it will default to nil.
Here's an example.
local function A_1(b) if a==nil then print('argument "b" is nil')-- printed end end; A_1()