A script that does not work with out any visible issues

I am working on a custom leaderboard GUI and it is not working correctly for no apparent reasons to me

This is the script:

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
wait(2)
local frame = script.Parent.stock
local players = 0
local positiondifference = 20

for i,v in pairs(game.Players:GetChildren()) do
	players = players+1
	local e = frame:Clone()
	e.Position = UDim2.new(0, 0, tonumber("0.0"..tostring(positiondifference*players)), 0)
        -- I made sure this works by printing the number created by tonumber("0.0"..tostring(positiondifference*players)).
	e.Text = v.Name
	e.Name = v.Name
end
script.Parent.Parent.loading:Destroy()

print(players) -- check to see if there was a ghost error, which there was not

game.Players.PlayerAdded:connect(function(p)
	players = players+1
	local e = frame:Clone()
	e.Position = UDim2.new(0, 0, 0, positiondifference*players)
	e.Text = p.Name
	e.Name = p.Name
end)

game.Players.PlayerRemoving:connect(function(p)
	if script.Parent:FindFirstChild(p.Name) then
		script.Parent[p.Name]:Remove()
	end
end)

The part of the script that seems to not operate correctly is this part: local e = frame:Clone()

It just dose not even work despite the fact it’s written in RAW CODE without any error being thrown out or given to me.

This is the format of the UI:
image

Thank you.

did you try to use it as a “script” or no?

You never set e.parent to anything so it’s created but parented to nil making it look like it didn’t work.

It’s in a local script, which I made sure did not effect anything

When an item is cloned every property stays the same when not changed in script, that is the normal behavior. But I will consider this and reply again if it works.

It seems to have worked. thank you.

1 Like

All properties clone except for the parent, it needs to be set manually.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.