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

How do I grab a player's name and insert it in a script?

Asked by
sirots 0
8 years ago

I've been trying a while now with a doorbell-like device. it has a ClickDetector and Script inside it and it's supposed to say something like "(playername) has rung your doorbell!". I can't figure out how to get the player's name! And it's driving me nuts. Please help me out ASAP!

Thanks...

1 answer

Log in to vote
1
Answered by 8 years ago

Parameter is a very clever way of identifying what actually triggered your events. Here's a example.

script.Parent.ClickDetector.MouseClick:connect(function(Click)--The Parameter can be given any string name you desire e.g "Click"
    print(Click)--This will print out the name of the Player that triggered the touch event
end)

~ UserOnly16Characters Hoped I helped you to answer your question! If you have any further question, don't hesitate to comment below!!

Edited:

script.Parent.ClickDetector.MouseClick:connect(function(Click)
    local Message = Instance.new("Hint",game.Workspace)
    Message.Text = Click.Name.." Has clicked this button"
    wait(3)
    Message:Destroy()
end)
0
Well thanks, but I want to use it in a hint message... how do I do that? sirots 0 — 8y
Ad

Answer this question