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

Why won't my GUI hide after deselecting Visibility?

Asked by 8 years ago
Edited 8 years ago

I am making a GUI which has a Show/Hide button. For some reason, this does not work. The other problem is when I try to run it in Roblox studio and change the visibility there, it does not turn off. There are no syntax errors detected by Roblox studio. This is also being used in a Seat so when you sit on it it gives you the GUI (will be placed in seat.

Here is the code:

Guithing = script.parent.parent.Frame --Only frame object there

function onClick()
    if Guithing.Visible == true then
        Guithing.Visible = false
    elseif Guithing.Visible == false then
        Guithing.Visible = true
    end
end

script.parent.MouseButton1Click:connect(onClick)

Here is the folder structure:

Seat

-StarterGui

--ScreenGui

---ControlGui

----Frame (To Hide)

-----...22 text labels...

----TextButton (Button To Hide)

0
Parents are capitalized... M39a9am3R 3210 — 8y

2 answers

Log in to vote
1
Answered by 8 years ago

Are there any errors in the output? Also I suggest replacing

function onClick()
    if Guithing.Visible == true then
        Guithing.Visible = false
    elseif Guithing.Visible == false then
        Guithing.Visible = true
    end
end
function onClick()
    Guithing.Visible = not Guithing.Visible
end

to take up less space

0
Would like to accept your answer for helping out but I can only give one :-( I will give you reputation instead RobskiT 5 — 8y
0
"but I can only give one" what do you mean? DeveloperSolo 370 — 8y
0
I can only accept 1 answer. RobskiT 5 — 8y
Ad
Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

parent needs to be Parent

and im assuming you tried to turn visible off in the StarterGui folder

in studio, you have to go to the player in Players and find the Gui and turn it off there

Guithing = script.Parent.Parent.Frame -- you probably need to change this now 

    function sit()
    Guithing.Visible == true 
end

function off()
Guithing.Visible == false
end


script.Parent.Touched:connect(sit)
script.Parent.TouchEnded:connect(off)

or to keep it your way


local player = game.Players.PlayerAdded() Guithing = script.Parent.Parent.Frame -- you probably need to change this now function sit() local clone = Guithing:Clone() clone.Parent= player.PlayerGui:FindFirstChild(sit.Name) clone.Visible = true end function off() player.PlayerGui:FindFirstChild(sit.Name).GuiThing:Destroy() end game.Workspace.Seat.Touched:connect(sit) script.Parent.Parent.Parent.Seat.TouchEnded:connect(off) -- name "Seat" what ever it is you are naming it in Workspace
0
This requires you to name specific players in the Player folder. This will be implemented in a seat and the GUI is meant to work for whoever is in the seat. Forgot to add that :P. RobskiT 5 — 8y
0
Read updated question RobskiT 5 — 8y
0
oh. used Touched for that AwesomeSauce666556 0 — 8y
0
if that doesnt work let me know AwesomeSauce666556 0 — 8y
View all comments (19 more)
0
Please update your answer with detail including the additional info. I just started coding, but I know the basics as Python works similarly. I have adapted to LUA, but don't know the functions etc. RobskiT 5 — 8y
0
for seat touch endedhttp://wiki.roblox.com/index.php?title=API:Class/BasePart/TouchEnded AwesomeSauce666556 0 — 8y
0
for seat touched http://wiki.roblox.com/index.php?title=API:Class/BasePart/Touched AwesomeSauce666556 0 — 8y
0
How do I find the GUI in Player folder? There is nothing there. RobskiT 5 — 8y
0
when you click play, you go to Players, (your name), Screen Gui AwesomeSauce666556 0 — 8y
0
If I am in studio (editing) it is not there. Also, you require the player name. The structure in-game is Players->RobskiT->ScreenGui. Not in studio. Also, any username needs to be able to access it. RobskiT 5 — 8y
0
oh. leave it the way it is. i was referring to " The other problem is when I try to run it in Roblox studio and change the visibility there, it does not turn off." AwesomeSauce666556 0 — 8y
0
The way your 2nd one is? RobskiT 5 — 8y
0
yea it should work AwesomeSauce666556 0 — 8y
0
Gui does not show when seated. RobskiT 5 — 8y
0
is the script in the seat or the gui? AwesomeSauce666556 0 — 8y
0
In the gui RobskiT 5 — 8y
0
is the gui in the seat? AwesomeSauce666556 0 — 8y
0
Affirmative (Yes) RobskiT 5 — 8y
0
where's the script at ? AwesomeSauce666556 0 — 8y
0
In the ControlGui Frame (See layout above) RobskiT 5 — 8y
0
try that AwesomeSauce666556 0 — 8y
0
Doesn't work. RobskiT 5 — 8y
0
oops. i put the wrong name. i was sleepy last night AwesomeSauce666556 0 — 8y

Answer this question