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

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

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

✓ Accepted answer

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)

1 comment

0

Well thanks, but I want to use it in a hint message... how do I do that?

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