Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

why is my printing, chatlogs script not working as i intended?

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.

2 answers

✓ Accepted answer

thats hard maybe a local script and use local Player = game.Players.LocalPlayer it maybe work try putting at line 10

38 comments

1

I’ll see what happens.

0

ok btw thanks for helping with my other questions ur a great friend

1

no problem also it works now thanks

1

have a great day

1

have a great day

1

have a great day

1

have a great day

1

have a great day

1

have a great day

1

have a great day

1

have a great day

1

have a great day

1

have a great day

0

bruh

1

big lag

1

oop sorry

1

oop sorry

1

oop sorry

1

oop sorry

1

oop sorry

1

oop sorry

1

oop sorry

1

oop sorry

1

oop sorry

1

oop sorry

1

oop sorry

1

oop sorry

1

oop sorry

1

oop sorry

1

oop sorry

1

oop sorry

1

oop sorry

1

oop sorry

1

oop sorry

1

Jesus crist-

1

Jesus crist-

0

stack overflow moment

0

lmao

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()

2 comments

0

yeah i think that would work

0

yeah i think that would work

This discussion is preserved as it was. New answers, comments, and votes are closed.