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

Shop Gui Won't Open, and says this when I try to open it. Why does it say this? And How do I fix it.

Asked by 4 years ago

So bassically I'm trying to make a shop gui. But when I put this script in for both my Close text label and Open text label. It says this: "10:36:29.846 - visible is not a valid member of ScreenGui"

Script For Close Text Label: script.Parent.MouseButton1Down:Connect(function() script.Parent.Parent.visible = false end)

Script For Open Text Label: script.Parent.MouseButton1Down:Connect(function() script.Parent.Parent.Frame.visible = true end)

4 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

I am gonna start of first on why it errored, The reason it errored is because you asking the visible property of a ScreenGui (see the error), but you ScreenGui doesnt have a visible property but it does have an Enabled property who does the similar, Secondly from further inspecting your code, its most like you because you accidently forgot to wrote .Frame in you first event.

Secondly you should use Visible instead of visible since it is deprecated

(in case both are refering to the same TextLabel) Thirdly you code doenst do what you think it does atm what it does is fire both functions: it sets Visible prop to true and to false, what you probably want it do is when its visible you want it to become invisble and when its visible you want to make it invisible

script.Parent.MouseButton1Down:Connect(function() 
    script.Parent.Parent.Frame.Visible = not  script.Parent.Parent.Frame.Visible
end)

so the above sets the current bool of Visible to the oposite, so when u click it sets it to Visible to false and when u click once more it sets it to true, etc...

(in case they arent reffering to the same TextLabel)

then all you have to do is fix the first function

script.Parent.MouseButton1Down:Connect(function() 
    script.Parent.Parent.Frame.Visible = false -- i just simply added .Frame, since you forgot to add it 
end)
0
Tysm, it works now! LostedMxnd 2 — 4y
Ad
Log in to vote
-1
Answered by 4 years ago
Edited 4 years ago

Maybe you could try this

script.Parent.MouseButton1Click:Connect(function(click) -- waits for click
if frame.Visible == false then -- checks if frame if not visible if it isnt visible then it will
frame.Visible = true -- make the frame visible
end
if frame.Visible == true then -- checks if the frame is visible if visible then
frame.Visible = false -- frame is visible
end
end)

so basicly if on click the script will detect if it is visible and if it is not it will make it visible vice-versa

0
this should do the trick Lamborghinihurican0 4 — 4y
0
Your answer doesn't explain anything. Pupppy44 671 — 4y
0
ill edit it Lamborghinihurican0 4 — 4y
0
@Pupppy44 please take off down vote i fixed it Lamborghinihurican0 4 — 4y
View all comments (2 more)
0
you should properly indent your code btw you can make that into a one liner like this `frame.Visible = not frame.Visible` VerdommeMan 1479 — 4y
0
its alright i like writing extra code anyways Lamborghinihurican0 4 — 4y
Log in to vote
-2
Answered by 4 years ago
Edited 4 years ago

its because your the 'v' in 'visible' should be an uppercase 'V' since 'visible' is not the same as 'Visible', the studio cannot find the thing you are referring to, 'visible' doesn't exist in ScreenGui, but 'Visible' does

therefore the message "10:36:29.846 - visible is not a valid member of ScreenGui" would appear

just change the 'v' in 'visible' to 'V' and it should solve your problem

0
Wrong, ScreenGui doesnt have a Visible property at all VerdommeMan 1479 — 4y
Log in to vote
-2
Answered by 4 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

I think this should work :

local frame = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame -- Set this to your Frame's name
script.Parent.MouseButton1Down:Connect(function()
frame.Visible = true (type "enabled" insted of "visible" because you can't just make screengui visible)
end)

local frame = game.Players.LocalPlayer.PlayerGui.ScreenGui
script.Parent.MouseButton1Down:Connect(function()
frame.Visible = false
end)
0
You need to explain what u changed, so that the person who asked the question understood what he did wrong, also you code is wrong, ScreenGui doesnt have a Visible property VerdommeMan 1479 — 4y

Answer this question