It warns button removed but I don’t understand why?
local function load(name, plrname)
local succ,err = pcall(function()
local plr = game.Players:FindFirstChild(plrname)
end)
if err then
warn("Player Could Not Be Found")
end
if succ then
local plr = game.Players:FindFirstChild(plrname)
if script.Buttons:FindFirstChild(name) then
local button = script.Buttons:FindFirstChild(name):Clone()
button.Parent = plr.PlayerGui:FindFirstChild('SimpleTopbar').Bar
else
error("Button Removed")
end
end
end
game.Players.PlayerAdded:Connect(function(player)
script.Assets.SimpleTopbar.Parent = player.PlayerGui
for index, instance in pairs(script.Buttons:GetDescendants()) do
load(instance.Name, player.Name)
end
end)
It’s because you are looping through the descendants, you need to loop through the children
local function load(instance, plrname)
local succ,err = pcall(function()
local plr = game.Players:FindFirstChild(plrname)
end)
if err then
warn("Player Could Not Be Found")
end
if succ then
local plr = game.Players:FindFirstChild(plrname)
local button = instance:Clone() -- Clones the button
button.Parent = plr.PlayerGui:FindFirstChild('SimpleTopbar').Bar
end
end
for i, v in ipairs(script.Buttons:GetChildren()) do
load(v, player.Name) -- Change sending the button name and just sends the whole button
end
You also can just sned the player over to the script not just it’s name