Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why doesn't this print work?

Asked by 9 years ago

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
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. M39a9am3R 3210 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago
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)

0
Thanks. Silly mistake ;p WelpNathan 307 — 9y
Ad

Answer this question