I am having problems cloning a frame in Roblox Studio. I have done it before without problems, but for some reason it will not clone the frame. In the same line I can change the properties of the template and print text. Any help would be highly appreciated.
local accessedPlayers = {324035128, 0}
local template = script.Parent.ScrollingFrame.Template
local function updatePlayerList()
print("Hello")
for i, v in pairs(game.Players:GetChildren()) do
if table.find(accessedPlayers, v.UserId) then
print("hi")
local newTemplate = template:Clone()
newTemplate.Name = v.Name
newTemplate.PlayerName.Text = v.Name
newTemplate.Visible = true
end
end
end
updatePlayerList()
game.Players.PlayerAdded:Connect(function()
updatePlayerList()
end)
When you Clone something it sets its parent to nil so you need to parent it to the ScrollingFrame again.
local accessedPlayers = {324035128, 0}
local template = script.Parent.ScrollingFrame.Template
local function updatePlayerList()
print("Hello")
for i, v in pairs(game.Players:GetChildren()) do
if table.find(accessedPlayers, v.UserId) then
print("hi")
local newTemplate = template:Clone()
newTemplate.Name = v.Name
newTemplate.PlayerName.Text = v.Name
newTemplate.Visible = true
newTemplate.Parent = template.Parent
end
end
end
updatePlayerList()
game.Players.PlayerAdded:Connect(function()
updatePlayerList()
end)