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

Textlabel getting moved each time a new one spawns?

Okay so i have this, custom ingame leaderboard.

Everytime i player joins it creates a textlabel, but i want the textlabel to move

{0, 0},{0.05, 0} each time a new one comes, so it isnt overlayed

CODE

game.Players.PlayerAdded:connect(function(player)

local label = Instance.new("TextLabel",script.Parent.SurfaceGui.Frame)

label.BorderSizePixel = 0
label.BackgroundTransparency = 1
label.Size = UDim2.new(1, 0, .05, 0)
label.Font = "ArialBold"
label.FontSize = "Size36"
label.TextColor3 = BrickColor.White().Color
label.TextStrokeTransparency = 0.5
label.Text = player.Name.." - "..player.userId

end)

1 answer

✓ Accepted answer

Well, I see no attempt of you trying to push its position down. What you need to do is set a variable, that would contain the last TextLabel, or its position. So:

LastLabel = nil

game.Players.PlayerAdded:connect(function(player)
	local label = Instance.new("TextLabel",script.Parent.SurfaceGui.Frame)
	label.BorderSizePixel = 0
	label.BackgroundTransparency = 1
	label.Size = UDim2.new(1, 0, .05, 0)
	label.Font = "ArialBold"
	label.FontSize = "Size36"
	label.TextColor3 = BrickColor.White().Color
	label.TextStrokeTransparency = 0.5
	label.Text = player.Name.." - "..player.userId
	if LastLabel ~= nil then
		label.Position = LastLabel.Position + UDim2.new(0, 0, .05, 0)
	end
	LastLabel = label
end)

game.Players.PlayerRemoving:connect(function(player)
	if script.Parent.SurfaceGui.Frame:findFirstChild(player.Name.." - "..player.userId) then
		script.Parent.SurfaceGui.Frame['player.Name.." - "..player.userId']:Destroy()
	end
end)

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