Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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)
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. TribotGamerGX 184 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago

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

0
could you please write it in a whole script for me or no QuestionableScript3r -6 — 4y
0
Andy_Wirus's answer is correct, I just put it into a script with some explanations skyaz1 72 — 4y
Ad
Log in to vote
0
Answered by
skyaz1 72
4 years ago

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

0
You probably know what this does I just have a habit of doing explanations of the scripts skyaz1 72 — 4y

Answer this question