Hey everyone,

I was just doing random stuff in a script and I thought I would ask what is wrong with this simple script, because it always errors in the output and I've never known why.

I wanted the script to print something whenever the player clicked on the click detector, but this error always appear on the output:

attempt to concatenate string with userdata

here is my simple script:

game.Workspace.Part.ClickDetector.MouseClick:Connect(function(plrthatclicked)
	print("Click Detector has been clicked by "..plrthatclicked)
end)

I don't see anything wrong with this... (its a serverscript by the way.)

Anyone know how to fix this? Or maybe its really simple and I'm just dumb? Thanks!

2 comments

0

The param 'plrthatclicked' gets the actual player that clicked the thing. It is not a string. You can use plrthatclicked.Name to get their name.

0

Thanks! I never realised!