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

Why doesn't this print work?

Hello, I just made a quick script. It is 5 lines long. It is just that I don't know how to use this script what I made!

If I remove the Player.. and "Clicked the button" it works fine. But I want it to print the Player Clicked the button! Help? Thanks.

The script is

function onClick(Player)
	print(Player.. "Clicked the button!")
end

script.Parent.ClickDetector.MouseClick:connect(onClick)

And the error is

11:39:21.066 - Workspace.Part.Script:2: attempt to concatenate local 'Player' (a userdata value) 11:39:21.067 - Stack Begin 11:39:21.067 - Script 'Workspace.Part.Script', Line 2 11:39:21.068 - Stack End

1 comment

1

Try Player.Name in the print line. "Player" is the player who clicked the button, which is a object value since your player is a object. Prints take string values, so a name or text would be string value, hence Player.Name should be in the parenthesis.

1 answer

✓ Accepted answer
function onClick(Player)
    print(Player.Name.. " Clicked the button!") -- You need to use the players' name (as M39a9am3R said), you used the actual player.
end

script.Parent.ClickDetector.MouseClick:connect(onClick)

1 comment

0

Thanks. Silly mistake ;p

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