this is my script
local window = game.ReplicatedStorage.StatsGUI.StatsWindow.Visible function onClicked(GUI) window = false script.Parent.MouseButton1Click:Connect(onClicked) end
Hi there, im BashGuy10. I have a simple script that you can adjust to your needs!
You should use :Connect(function()
. As this makes it much cleaner.
local window = script.Parent.Parent.Frame -- Change this to your location script.Parent.MouseButton1Click:Connect(function() if window.Visible == true then window.Visible = false end end)
Hope this helps!
I think it because you connected the function inside the function itself, this way, the function will never activate
you should connect the function outside the function instead:
local window = game.ReplicatedStorage.StatsGUI.StatsWindow.Visible function onClicked(GUI) window = false end script.Parent.MouseButton1Click:Connect(onClicked)
`