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

Weapon Shop GUI, SetCoreGUI Enabled = false Not Working?

So I have a weapon shop, and if you click on this button on the side of your screen the shop is visible. I have it so that to make space for the GUI the core GUI's are disabled, but if the frame is not visible the GUI's are enabled. Here's the script:

frame = game.StarterGui.WeaponShopGUI.WeaponShopFrame
script.Parent.MouseButton1Click:connect(function()
	
script.Parent.Parent.WeaponShopFrame.Visible = not script.Parent.Parent.WeaponShopFrame.Visible
if frame.Visible == true then
	local StarterGui = game:GetService('StarterGui')
    StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
elseif frame.Visible == false then
	local StarterGui = game:GetService('StarterGui')
    StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
end
end)

if you click the button once, it works, but if you click it again to exit it, it stays disabled, any help? Also as a side question if a frame is not visible is it still enabled, I don't want my players to accidentally buy a gun, and if it is how do I change that?

1 answer

✓ Accepted answer

Try this. I fixed and tested it and it should work :

wait(1)
local frame = game.Players.LocalPlayer.PlayerGui.WeaponShopGUI.WeaponShopFrame
script.Parent.MouseButton1Click:connect(function()
	frame.Visible = not frame.Visible
	if frame.Visible == true then
    	local StarterGui = game:GetService('StarterGui')
    	StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
	elseif frame.Visible == false then
    	local StarterGui = game:GetService('StarterGui')
    	StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
	end
end)


Also don't use StarterGui when you want to change things just for 1 player. StarterGui clones GUI to everyone when they respawn or join.

1 comment

0

thanks!

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