How can you use a script to clone a template on join

You can write your topic however you want, but you need to answer these questions:
1. What do you want to achieve? Keep it simple and clear!
i want the script to clone the template into the scrolling frame when the player joins with the template name being the player’s name

2. What is the issue? Include screenshots / videos if possible!
The issue is that the template isnt cloning into the scrolling frame

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
it needs to be the exact username of the player.

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Is there a way to fix this?

game.Players.PlayerAdded:Connect(function(player)
     local clone = template:Clone()
     clone.Parent = player.PlayerGui.DevCMDS.MainFrame.PlayerList
     clone.Name = player.Name
end)

if you want one that constantly updates, i wouldnt be too keen on how to do that… otherwise, this should work locally.

I do need one that updates, because I’m trying to make an admin panel.

it needs to show constantley every player and player name

You’d need a localscript for that (StarterPlayer > StarterPlayerScripts in explorer)

local plr = game.Players.LocalPlayer

for i, v in pairs(game.Players:GetChildren()) do
          if v.Name ~= plr.Name then
                local clone = template:Clone()
                clone.Parent = plr.PlayerGui.DevCMDS.MainFrame.PlayerList
                clone.Name = v.Name
     end
end

after this is set up, we need to have a function:


--this will update the gui once a player is added

game.Players.ChildAdded:Connect(function(child)
     local clone = template:Clone()
     clone.Parent = plr.PlayerGui.DevCMDS.MainFrame.PlayerList
     clone.Name = child.Name
end)

--and this will update it when a player is removed/leaves

game.Players.ChildRemoved:Connect(function(child)
     plr.PlayerGui.DevCMDS.MainFrame.PlayerList[child.Name]:Destroy()
end)

alright ill try your script but in a local script this time

alright im a little confused here was i supposed to add the 2nd line of code in my script or no?

You need to add all of them, the for i, v in pairs and the other 2 childadded and childremoved events. This is the only script you need for this system. Also remember to define the template.

(473) Recording 2023 07 23 175226 - YouTube

i think it works now i just took your script but instead of adding [child.Name] i put :FindFirstChild(child.Name):Destroy

Sounds good, glad this solution worked for you. Keep developing!

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