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)
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)
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
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
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)