[HELP] GUI Disappears When Clicking Button — How Do I Fix This?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want to make a functional GUI in Roblox that stays visible after players click a button. The button should trigger a specific action (when opening a new frame) without making the entire GUI disappear. Its basically like when i equip a character the shop frame should disappear but shop button (to open shop) has to stay visible so the player can re-open the shop frame

  1. What is the issue? Include screenshots / videos if possible!

The issue I’m encountering is that whenever I click the equip button after bying in my frame, the shop button disappear or completely vanish from the screen instead of one of the buttons in the frame saying “equipped” . I’ve checked my scripts and can’t seem to figure out what’s causing this behavior.

Here’s a screenshot of the GUI before and after clicking the button:

Before (when opening the shop frame through shop button

After (when clicking the equip button)

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I’ve tried the following solutions:

  • Checked the button’s MouseButton1Click event for any Destroy(), Visible = false, or Parent = nil lines of code.
  • Searched through the Developer Hub and other forums for similar issues but didn’t find a solution that worked for me.
  • Made sure the GUI’s ResetOnSpawn property is set to false to prevent it from disappearing when a player respawns.

Despite these attempts, the problem persists.

Here’s a snippet of my current frame/shop/equip button script:

local player = game.Players.LocalPlayer
local replicatedStorage = game:GetService("ReplicatedStorage")
local equipButton = script.Parent:WaitForChild("EquipButton")
local shopFrame = script.Parent
local screenGui = script.Parent.Parent
local coinLabel = game.StarterGui.ScreenGui:WaitForChild("CoinDisplay")
local shopButton = script.Parent.Parent:WaitForChild("ShopButton")
local closeButton = script.Parent:WaitForChild("CloseButton")

local characterFolder = replicatedStorage:WaitForChild("Characters")
local characterName = "FireCharacter"  -- Replace with your character's name
local characterPrice = 100  -- Replace with your desired price

-- Update Button Function
local function updateButton()
	local ownedCharacters = player:FindFirstChild("OwnedCharacters")
	if ownedCharacters and ownedCharacters:FindFirstChild(characterName) then
		equipButton.Text = "Equip"
	else
		equipButton.Text = "Buy for " .. characterPrice .. " Coins"
	end
end

equipButton.MouseButton1Click:Connect(function()
	local ownedCharacters = player:FindFirstChild("OwnedCharacters")

	if equipButton.Text == "Buy for " .. characterPrice .. " Coins" then
		-- Buy Logic
		if player.Coins.Value >= characterPrice then
			player.Coins.Value -= characterPrice

			if not ownedCharacters then
				ownedCharacters = Instance.new("Folder")
				ownedCharacters.Name = "OwnedCharacters"
				ownedCharacters.Parent = player
			end

			local characterTag = Instance.new("BoolValue")
			characterTag.Name = characterName
			characterTag.Parent = ownedCharacters

			updateButton()
		else
			equipButton.Text = "Not Enough Coins!"
			wait(1)
			updateButton()
		end
	elseif equipButton.Text == "Equip" then
		-- Equip Logic
		local characterModel = characterFolder:FindFirstChild(characterName)
		if characterModel then
			local newCharacter = characterModel:Clone()
			newCharacter.Parent = workspace
			player.Character = newCharacter
			workspace.CurrentCamera.CameraSubject = newCharacter:FindFirstChild("Humanoid")
			equipButton.Text = "Equipped"
		end
	end

	-- Keep the GUI elements visible
	shopFrame.Visible = false
	shopButton.Visible = true
	coinLabel.Visible = true
end)


updateButton()

1 Like

check the properties of the screengui instance, it has some property like reset on respawn (i cant remember the exact name), try checking it off.

1 Like

no way it actually worked! i cant believe a simple property could make a change on the gui, tysm :smile:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.