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

Why is this function script not working?

I am trying to script a leaderboard type thing that shows a list of players in the game. Not the regular roblox one. Its in a frame that list people in the server. For example: (names of people in the game) TrollD3, BSInc., Swagg, DeezNuts, guest2334, idgaf532, Gottem321, would all be in a column. The goal is to get the script to put the names of everyone in texboxes. So when a new player is added, a new textbox appears, and when they leave, it disappears.

This is the script I have so far: EDITED!! I want the name to be posted inside the txtbutton and to remove that textbutton when someone leaves. Its not working. This is the remade script:

--OnEnter:
lol = 5

game.Players.PlayerAdded:connect(function(p)--Here 
script.Parent.Text = "p.Name" 

script.Parent.Parent.Position = script.Parent.Position + UDim2.new(0,0,lol*1.6,0)   
end)

-- OnLeave:

game.Players.ChildRemoved:connect(function(p)-- Here
 script.Parent.Text = "p.Name" 
script.Parent.Parent.Position = script.Parent.Position + UDim2.new(0,0,lol/1.6,0)
end)


2 answers

✓ Accepted answer

p.Name is not "p.Name". They're two different things.

print(p.Name) will output the player's name. print("p.Name") will output exactly what's between the quotation marks, "p.Name".

Like funyun said, you need to use p.Name without the quotations. This because it will print exactly what you put. To fix this just use the code below. Just replace line 5 and 13 with this, so it will show the player's name.

script.Parent.Text = p.Name

Replacing your lines with this, it will show the player's name instead of showing "p.Name", like you don't intend it to do.

Accept my answer and give me upvote if it worked!

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