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

my about gui and code generally wont work how to fix?

im trying to make an about the game thing and when you press the button its supossed to make a frame visble value true and a bool value true i dont know why it wont work

heres the code

local ABOUTButton = script.Parent
local IsOpenBool = script.Parent.IsOpen

local function Open()
	game.StarterGui.MENU.ABOUTBACKROUND.Visible = true
	IsOpenBool.Value = true
end

local function Checkifopen()
	if IsOpenBool.Value == true then
		IsOpenBool.Value = false
		game.StarterGui.MENU.ABOUTBACKROUND.Visible = false
	end
end

ABOUTButton.MouseButton1Click:Connect(function()
	Open()
	Checkifopen()
end)

1 comment

0

When changing a bool's value, you can't say IsOpenBool.Value == true, you will have to say IsOpenBool == true. I know it sounds strange, but it worked for me.

2 answers

Instead of game.StarterGui use Player.PlayerGui. StarterGui is not visible to the player, all that it does is whenever you spawn it clones everything inside to PlayerGui

2 comments

0

could you please write it in a whole script for me or no

0

Andy_Wirus's answer is correct, I just put it into a script with some explanations

READ: Overall this is a good script aside from the errors. First, this needs to be in a local script(which it is probably). Also, the main problem with the script is that you tried to get to the gui through startergui(a common mistake), if this is a local script(which it has to be to work and also you should always use localscripts for guis), then you can get to the player and their gui through: game.Players.LocalPlayer.StarterGui, the rest is exactly what is in startergui. Third of all, I put everything into a single mouseclick function to make it more simple. Basically, this edited version of your script activates a function that checks if it is either open or closed on mouseclick. Hope this helped :)

	local ABOUTButton = script.Parent
	local IsOpenBool = script.Parent.IsOpen
	 
	local function OpenorClose() -- this function is for both opening and closing using ifs
   
	if IsOpenBool.Value == false then -- if it is closed then open it
	game.Players.LocalPlayer.PlayerGui.ScreenGui.MENU.ABOUTBACKROUND.Visible = true

	   	 
		IsOpenBool.Value = true 
	
	end
	    elseif IsOpenBool.Value == true then --use elseif because there is already an if in the function
	        IsOpenBool.Value = false  game.Players.LocalPlayer.PlayerGui.ScreenGui.MENU.ABOUTBACKROUND.Visible = false
	    end
	end
	 
	 ABOUTButton.MouseButton1Click:Connect(OpenorClose)

Note: There may be minor typing mistakes in the script

1 comment

0

You probably know what this does I just have a habit of doing explanations of the scripts

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