So i have a player list and i have it create a text label for each player that joins but the label doesn’t fit on all screens and i cant use a plugin to fix this because a script is creating the label. here’s the part of the script that creates the label:
local function makebox(name, current)
local listed = Instance.new("TextLabel", playerlist)
listed.Position = UDim2.new(0.032,0,0.013,current*60)
listed.Name = name
listed.Text = name
listed.BackgroundColor3 = script.Parent.ListTitle.BackgroundColor3
listed.TextStrokeColor3 = script.Parent.ListTitle.TextStrokeColor3
listed.TextStrokeTransparency = 0
listed.Size = UDim2.new(0.929, 0, 0.072, 0)
listed.TextScaled = true
listed.TextColor3 = Color3.new(1, 1, 1)
listed.Font = "Cartoon"
local Corner = Instance.new("UICorner", listed)
end
I think I would need to do something with the size/position things but I don’t know how
Maybe it is because of that you are using an Offset value here:
(current*60 is written in Offset).
The best solution is to create a TextLabel template somewhere, for example parented to the script and just :Clone() it (you would have more control over customizing the label).
I replaced local listed = Instance.new("TextLabel", playerlist)
with local listed = script.Username:Clone()
but it didn’t work is there something I’m doing wrong (sorry I’m not that good at scripting)
What is the error in the first place? You can provide a screenshot.
well the error I want to solve is the text label not scaling right for different devices so I tried cloning the template each time a player joined to put their name on the list but it didn’t work
I need to know the error reported by a Script in the Output window (View > Output).
Ok I’m on an iPad rn so when I’m able to use my computer ill send it to you
I’m checking for the error rn but I also parented the label to the frame with a script to see if that would make it appear
Okay it didn’t work I think it broke the script I’m checking to see if there are any errors
This is the error and I’ll show you the line of the script
This is the whole script:
local startergui = game:GetService("StarterGui")
local players = game:GetService("Players")
local listframe = script.Parent
local playerlist = listframe.ListPlayers
--default list disable, remove if you're already doing this
repeat
local load = pcall(function()
startergui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
end)
wait(0.2)
until load
local function makebox(name, current)
local listed = script.Template:Clone()
listed.Parent = "ListPlayers"
listed.Position = UDim2.new(0.032,0,0.013,current*60)
listed.Name = name
listed.Text = name
--you can use your own values here
listed.BackgroundColor3 = script.Parent.ListTitle.BackgroundColor3
listed.TextStrokeColor3 = script.Parent.ListTitle.TextStrokeColor3
listed.TextStrokeTransparency = 0
listed.Size = UDim2.new(0.929, 0, 0.072, 0)
listed.TextScaled = true
listed.TextColor3 = Color3.new(1, 1, 1)
listed.Font = "Cartoon"
local Corner = Instance.new("UICorner", listed)
end
local function reload() --this reloads the player list when called
for _,v in pairs(playerlist:GetChildren()) do
v:Destroy()
end
for _,v in pairs(players:GetChildren()) do
makebox(v.Name, #playerlist:GetChildren())
end
end
local isActive = false
userinput.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Tab then --will show/hide with tab
if not isActive then
reload() --updates on tab press
isActive = true
listframe.Visible = true
else
isActive = false
listframe.Visible = false
end
end
end)
--updates on player join/leave
players.PlayerAdded:Connect(reload)
players.PlayerRemoving:Connect(reload)
reload()
The Parent property is wrong here. If you want to Parent ‘listed’ to something, you would have to do (this is just an example assuming that you want to Parent the thing to Script’s Parent):
listed.Parent = script.Parent
Okay it worked thanks for helping