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

I need help with a Toggle Visibility script? SOLVED

Asked by
Asirix 15
10 years ago

So, I really have no clue at this point. I was told to you elseif instead of if in the 4 fourth line. Well... it didn't work. SO, I guess I need some help.

Here it is:

script.parent.MouseButton1Click:connect(function(Open)
    if game.StarterGui.ExploreID.ProfileShade.Visible==false then
     game.StarterGui.ExploreID.ProfileShade.Visible=true
    elseif game.StarterGui.ExploreID.ProfileShade.Visible==true then
        game.StarterGui.ExploreID.ProfileShade.Visible=false
    end
end)

I have also tried.

function open()
    if game.StarterGui.ExploreID.ProfileShade.Visible==false then
     game.StarterGui.ExploreID.ProfileShade.Visible=true
    elseif game.StarterGui.ExploreID.ProfileShade.Visible==true then
        game.StarterGui.ExploreID.ProfileShade.Visible=false
    end
end

script.Parent.MouseButton1Click:connect(open)

Any suggestions or fixes?

Wow, it was actually very easy. Redid the code. XD

function open()
    script.Parent.Parent.Parent["ProfileShade"].Visible = not script.Parent.Parent.Parent["ProfileShade"].Visible
end

script.Parent.MouseButton1Click:connect(open)

2 answers

Log in to vote
0
Answered by 10 years ago

Well you don't really need elseif, given that you are checking if it's not visible... That means there are only two possible things that could happen so if the first one is false the other one has to be true. Just put an else and see if it helps somehow

Ad
Log in to vote
0
Answered by
u_g 90
10 years ago

I'm not sure, but maybe it's because you're using "game.StarterGui". You see, if this is a Gui inside of your "game.Players.Player.PlayerGui", then you would need to use that instead of "game.StarterGui". Right now, I think you're changing the visibility of the Gui that is in the StarterGui, and not the one that is actually in your PlayerGui.

Answer this question