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 Acquire someone's username and then use it to automatically edit a text box?

My current code is:

function onclick(player)
tools=player.Backpack:GetChildren()
if(player:FindFirstChild("Bags"))==nil then
folder=Instance.new("Folder")
folder.Name="Bags"
folder.Parent=player
else
player.Bags:ClearAllChildren()
end
for i=1,#tools do
if (tools[i]:FindFirstChild("Bag"))~=nil then
tools[i].Parent=player.Bags
end
end
location=script.Parent.Parent.Location.Position

baghold=player.Bags:GetChildren()

for i=1, #baghold do
wait(1)
baghold[i].Parent=Workspace
baghold[i].Handle.CFrame=CFrame.new(location)
if(baghold[i].Handle:FindFirstChild("Tag"))==nil then
tag=script.Tag:Clone()
tag.Parent=baghold[i]:FindFirstChild(baghold[i].MainPart.Value)
tag.Player.Text=player.Name
end
end

end
script.Parent.ClickDetector.MouseClick:connect(onclick)	

But I was wondering how I get someone's username and then it edits a text box to the player's name.

Script layout: http://prntscr.com/8ti0tg

1 comment

0

Well it really depends on WHO's username you're acquiring.

1 answer

✓ Accepted answer

Aight, get username then edit a textbox to it. Got it

If you are using a ClickDetector then it is easier since it returns the Player on click. You need to create the function and connect it with the ClickDetector. [ CONTENT DELETED ]

So here is the function and connection:

local function Click(Player)

end

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

Then you actually add the code that changes the TextLabel's Text into the Player's name. Pretty basic stuff:

local function Click(Player)
script.Tag.Player.Text = Player.Name
end

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

2 comments

0

Thank you so much.

1

You're welcome man :)

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