Gui Not Closing

Hello, so I have a problem when my gui opens it closes when this is in a script, but not a local script, how do I make this script work with a local script? Also just to say this is to open it, but I have tested and this is the problem it only closes when this certain scripts in a script instead of local.

script.Parent.MouseButton1Click:Connect(function()

	script.Parent.Parent.Parent.Parent.Parent.TeamChooser.Enabled = true

end)

1 Like

Can you show your explorer so I can see how you have parented your objects?

image

It depends on the ui, if your planning to close it, there is a “Visible” property. And whats with the parents?

You need only 4 parents (to the screen ui) if your selecting something else within it. Where is TeamChooser?

You can see it on the bottom of the screenshot.

local StarterGui = game.StarterGui
local TeamChooser = StarterGui.TeamChooser;

local Button = script.parent;

Button.MouseButton1Up:Connect(function()
 TeamChooser.Enabled = true;
end)

I don’t think disabling it will do anything, my guess is to make a ui that contains all of the ui visible false l

Yea, that script makes it so It doesnt open now, I don’t know whats wrong with it.

Can you tell me what you’re trying to do, so maybe I can help you.

Hold up Server Script?, you can’t do ui scripting on the server…

Basically its a team gui, and I am trying to make the change team gui close, because currently it wont close, here is the change team script, and then the change team script.

local gui = script.Parent
local player = script.Parent.Parent.Parent


for _, child in pairs(script.Parent:GetChildren())do
	local index = child.Name:find("Selection")
	
	--if the child is a team selection button:
	if index then
		local teamName = child.Name:sub(1, index-1)
		print(teamName)
		child.MouseButton1Click:connect(function()
			player.Team = game:GetService("Teams"):FindFirstChild(teamName)
			gui.Enabled = false
		end)
	end
end

script.Parent.MouseButton1Click:Connect(function()
	game.Players.LocalPlayer.PlayerGui.TeamChooser.KidsSelection.Visible = true
	game.Players.LocalPlayer.PlayerGui.TeamChooser.TeensSelection.Visible = true
	game.Players.LocalPlayer.PlayerGui.TeamChooser.ParentsSelection.Visible = true
	game.Players.LocalPlayer.PlayerGui.TeamChooser.Enabled = true
end)

I don’t think you’re supposed to be editing startergui,

local gui = game.Players.localplayer.PlayerGui

If you want to edit a PLAYER’S gui do this.

Yeah I know, that starter gui stuff clones into the player’s gui, I just did it for the ease but @Kevblx check @Phazenine 's code out to see.

I still havnt found a solution, and yes I tried that. I really am confused on why this isnt working

So you are trying to change the team when ever the player closes the gui?

No, can I send you a copy of the place so you may understand better, and can take a more detailed look.

Ok sure, if you want just send me the ui stuff and the scripts

Give.rbxl (140.2 KB)

1 Like

It works, you made a simple mistake by using a server script instead of a local, I recommend you familiarize your self with Server Scripts, Client Scripts, Roblox server modal.

Give {solved}.rbxl (139.9 KB)