The script probably loads faster than the GUI itself. Try putting the script inside the OpenButton, that might solve it. And/or use :WaitForChild
Example:
local Button = ScreenGui:WaitForChild("OpenButton")
This is because youāre not using āMouseButton1Clickā, using āActivatedā isnāt a valid usage of GUI.
local Player = game:GetService("Players").LocalPlayer
local PlayerGui = Player.PlayerGui
local Frame = PlayerGui.ScreenGui
local Button = PlayerGui.ScreenGui.OpenButton
Button.MouseButton1Click:Connect(function()
frame.Visible = false
end)
But it is, hereās the documentation
https://developer.roblox.com/en-us/api-reference/event/GuiButton/Activated
āFires when the button is activated.ā
Thank you so much everybody!! Thanks for your time
This detects after itās been clicked, not to process a click.
I actually worded it wrong, so I apologize, I was meaning it wasnāt a valid use for registering clicks.
Iād recommend putting the LocalScript in the ScreenGui and using this source.
local screengui = script.Parent
local button = screengui:WaitForChild("OpenButton")
local target = screengui:WaitForChild("Frame")
button.MouseButton1Up:Connect(function()
if typeof(target) == 'Instance' and target:IsA("GuiObject") then
target.Visible = true -- or you can do 'target.Visible = not target.Visible' for a toggle.
end
end)
If something worked, mark a message as solution, so that this can close.
Oh okay, I didnāt know that. In this case, they should reword the documentation, Iām sure Iām not the first one who got confused
Oh yeah for sure, it is confusing. For a little clarification, Activated can be used if youāre going from a script to another, like if you use āMouseButton1Clickā in one script, and then another script will pick up when it got activated.