I want to make this script create a textbutton each time a player enters and when they leave the button will be destroyed. Please help i have been on this same script for the past few days. I seriously need help with this.
A look at my explorer: http://gyazo.com/dc737ffcde271877b05b4d0f6e846c10
function edit(plr)
for num,p in pairs(game:GetService("Players"):GetPlayers()) do
for _,obj in pairs(script.Parent.Parent:GetChildren()) do
if obj.Name == "Player" then
obj:Destroy()
end
end
local gui = script.Parent:clone()
gui:ClearAllChildren()
gui.Position = gui.Position + UDim2.new(0, 0, 0, (num-1)*50)
gui.Visible = true
gui.Parent = script.Parent.Parent
gui.Name = "Player"
gui.Text = plr.Name
end
end
game.Players.PlayerAdded:connect(edit)
game.Players.PlayerRemoving:connect(edit)

2 comments
I need more information. So, when the player enters the SERVER, they are given a gui, but when they leave the SERVER, it's removed?
@alphawolvess exactly correct!