I'm creating a custom player list for my game, which runs off of RemoteEvents. When I fire the event it should create a Frame for every player, which it does successfully, and updates the GUI in the storage.
local lastPosition = -30
game.ServerScriptService.RefreshPlayerList.OnServerEvent:connect(function()
removeGUIs()
lastPosition = -30
local gui = game.ServerScriptService.CustomPlayerList
for i,v in pairs(game.Players:GetPlayers()) do
local example = gui.ScrollingFrame.Example:Clone()
example.Parent = gui.ScrollingFrame
example.Position = UDim2.new(0,0,0,lastPosition + 30)
lastPosition = lastPosition + 30
example.Player.Text = v.Name
example.Rank.Text = v:GetRoleInGroup(2654781)
example.Visible = true
example.Name = v.Name
example.Parent.CanvasSize = UDim2.new(0,0,0,lastPosition + 30)
end
end)
But then I try to remove all the player's GUI's, which it does, and then try add the one from the storage, it doesn't clone..
local function removeGUIs()
for i,v in pairs(game.Players:GetChildren()) do
v.PlayerGui:FindFirstChild("CustomPlayerList"):Destroy()
end
print("removed")
wait()
--From here
local newGui = game.ServerScriptService.CustomPlayerList:Clone()
for u,x in pairs(game.Players:GetPlayers()) do
newGui.Parent = x.PlayerGui
print("Removed from "..x.Name)
end
--To here
print("added") --Yet this prints...
end

1 comment
Psst, this is a script running off of RemoteEvents! But yeah, this worked in a way, but I had to put ALL the functions into the main one, but thanks for that.