I don't know what I need to put for the ..username.. part.
textButton = script.Parent
textButton.MouseButton1Down:connect(function()
print "Hello there"..username.."."
end)
I don't know what I need to put for the ..username.. part.
textButton = script.Parent
textButton.MouseButton1Down:connect(function()
print "Hello there"..username.."."
end)
-- LocalScript
local textButton = script.Parent
local me = game.Players.LocalPlayer
textButton.MouseButton1Click:connect(function()
print("Hello there, "..me.Name)
end)
You must define username.
The easiest way to access a user's username is to go through a string of parents. In this instance:
script.Parent.Parent.Parent.Parent
Because the script is a member of TextButton which is a parent of ScreenGui which is a parent of PlayerGui which is a parent of Player, which has a property called .Name. Here's a fixed script:
textButton=script.Parent
username=script.Parent.Parent.Parent.Parent.Name
textButton.MouseButton1Down:connect(function()
print "Hello there "..username.."."
end)
You can read more about GUI's here.
You need to define what Username is. To do that, do this in a localscript:
local Username = game.Players.LocalPlayer
you can read about ontouched events for parts here. or else, click here to go to a page in the wiki explaining about LocalPlayer. hope this helped! Remember:
Always define something that the script/localscript can't recognize!
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
The best way is to use a LocalScript and use LocalPlayer.