My GUI should be hidden when i hit a button on my GUI., but it for some reason is not working

I am currently trying to make a gui that when, one of its buttons are pressed that it goes invisible. The code is below. Doesnt work at all!

BELOW IS ONLY THE FUNCTION!!! I DID MAKE THE FUNCTION RUN!!!

local function choose()
	
	script.Parent.Frame.Visible = not script.Parent.Frame.Visible

end
  1. What do you want to achieve? I want my GUI to close when a team is picked by the player.

  2. What is the issue? It wont close at all.

  3. What solutions have you tried so far? I have tried to do many methods of hiding it, but none worked.

If you can help, you would have contributed to the Roblox Community!

1 Like

Did you connect the function to MouseButton1Click? Is this your full script? If not, could you show your full script?

3 Likes

This is the full script! Thank you for trying to help too!

local RemoteEvent = game.ReplicatedStorage.ChangeTeam 

local frame = script.Parent:WaitForChild("Frame") 

local blue = "Bright blue"

local red = "Bright red"

local function choose()
	
	script.Parent.Frame.Visible = not script.Parent.Frame.Visible

end

frame.Red.MouseButton1Click:Connect(function() 

	RemoteEvent:FireServer(BrickColor.new(red))

	choose()

end)

frame.Blue.MouseButton1Click:Connect(function()

	RemoteEvent:FireServer(BrickColor.new(blue))

	choose()

end)
1 Like

Are there any errors in the output? If so, could you show what the error is?

2 Likes

it doesnt show any errors in the output.

2 Likes

Maybe try this:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage:WaitForChild("ChangeTeam")

local Frame = script.Parent:WaitForChild("Frame")
local RedBtn = Frame.Red
local BlueBtn = Frame.Blue

local BlueColor = "Bright blue"
local RedColor = "Bright red"

RedBtn.Activated:Connect(function()
	Event:FireServer(BrickColor.new(RedColor))
	Frame.Visible = not Frame.Visible
end)

BlueBtn.Activated:Connect(function()
	Event:FireServer(BrickColor.new(BlueColor))
	Frame.Visible = not Frame.Visible
end)

Are you trying to make the Frame invisible, or the Button that was clicked invisible?

game.Players.PlayerAdded:Connect(function(player)
player.PlayerGui:WaitForChild("NameOfGUI").ShopGuiBackground.Visible = false
player.PlayerGui:WaitForChild("NameOfGUI").OpenButton.Visible = true
end)

Try this

Just Edit the ShopGuiBackground and OpenButton to your main GUI names

I have to tell you that it is a team changing GUI that will close when the button is pressed, not a shop It will not open when you press a button…

I tested and it did not work. Again, thank you! I am trying to hide the frame which the whole ui is a child of the frame

Yea ur right sorry I was kinda confused XD

It doesnt bother me! I hope I didn’t hurt you too much.

1 Like

Strange. The code you have provided (not mines) should have worked. I honestly dont see anything wrong with the code you provided, nor mines.
Could you show an image of the ScreenGui that shows the Frame, the buttons, and the script in the explorer menu?

Of course. Let me get it… :slight_smile:

1 Like

Screen Shot 2021-08-18 at 4.14.01 PM

This is my UI in the explorer

1 Like

I really dont see any problem with the code you have provided and the code I have provided as well. Are you sure there is no errors (OR warnings) in the output? Because if there’s not, then I have no idea what’s the problem. Maybe your remote event was named something else or…?

1 Like

I checked again and there was no errors or warnings… I am still happy you were able to help. :smiley: It means the world to me when people help me.

1 Like

I have no problem helping. You are very welcome.
We still need to solve this problem though.

I personally think that your help is making me a better programmer!

I agree. We do need to fix this issue.

Ill continue looking through my code!

1 Like

Nah it’s all good. I am new to scripting too.