Why is this not working?

I’m trying to figure out why this script won’t work.

The ScreenGui is Enabled and I don’t get why it’s not being changed to false when the button is clicked on.

local ClickSound = game.SoundService.ClickSound
local Button = script.Parent
local isHovering = false
local AgreementGui = game.StarterGui.NotificationGui

Button.MouseEnter:Connect(function()
	isHovering = true
	Button:TweenSize(UDim2.new(0.72, 0, 0.17, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
end)

Button.MouseLeave:Connect(function()
	isHovering = false
	Button:TweenSize(UDim2.new(0.7, 0, 0.15, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
end)

Button.MouseButton1Click:Connect(function()

	if AgreementGui.Enabled == true then
		AgreementGui.Enabled= false
		ClickSound:Play()
	end

end)

You might’ve figured this out already, but it’s not working because the local script doesn’t actually run until it’s a descendant of PlayerGui. Easy mistake.

So this local AgreementGui = game.StarterGui.NotificationGui should be something like local AgreementGui = script.Parent.Parent

Managed to fix it I appreciate your feedback