I want to make a button that when clicked, will get a list of all players.
The only problem to this is that the button is invisible/transparent but in the code, I made all transparency values to 0 and visible
to true
local kick = script.Parent local function Choose() local players = game.Players:GetPlayers() for i = 1,#players do local newgui = Instance.new("TextButton") newgui.Name = "newgui" newgui.Parent = game.StarterGui.ScreenGui newgui.BackgroundTransparency = 0 newgui.Visible = true newgui.ZIndex = 1 newgui.Position = UDim2.new(0.5, 0,0, 0) newgui.Size = UDim2.new(0, 200,0, 50) newgui.Text = tostring(players[i]) end end kick.MouseButton1Click:Connect(Choose)
I can see it is on the screen by selecting it in the explorer but it is just invisible. The text value is equal to denbra37 but it is transparent too.
First of all, you can't use StarterGui, because it immediately replicates to the PlayerGui. That's why it doesn't work. You need to set the parent to the PlayerGui and not the StarterGui.
local kick = script.Parent local function Choose() local players game.Players:GetPlayers() for i, v in pairs(players) do --I suggest using an in pairs loops instead, as it is more efficient. local gui = Instance.new("TextButton") gui.Name = "newgui" gui.Parent = v.PlayerGui gui.BackgroundTransparency = 0 gui.Visible = true gui.ZIndex = 1 gui.Position = UDim2.new(0.5,0,0,0) gui.Size = UDim2.new(0,200,0,50) gui.Text = tostring(players[i]) end end kick.MouseButton1Click:Connect(Choose)