Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make the textButton appear ?

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.

4 comments

0

I don't if this will help, but maybe try creating a frame that will hold all your text buttons, then set the frame visible? Also, is the 'ScreenGui' already existing? Maybe you need to define it beforehand.

0

uhhh maybe try at the end visible = false?

0

screenGui is already existing

0

I've parented it to a frame but it doesn't work too even if frame.ten

1 answer

✓ Accepted answer

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)

1 comment

0

There was a bit of error but I corrected them of my own, thx !

This discussion is preserved as it was. New answers, comments, and votes are closed.