Gui button not working

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?

I want to close the settings menu.

  1. What is the issue?

The close button is not closing the gui. I am using a module and it works for other scripts using the module script.

  1. What solutions have you tried so far?

I have tried changing the events but no luck so far. I looked in the Roblox Developer hub. At around 10 threads. I have looked in every single page I could find on Google. It has been ONE MONTH since this problem arose. I am getting tired of spending almost every single day of my life trying to fix this glitch. I am losing it. This might sound desperate and that is because I am.

A video that might help

Module Script

function module.tween(parent, x, ogy, close)
	local function update()
		if parent.Visible == true then
			parent.Position = UDim2.new(x, 0, 1, 0)
			local tween = parent:TweenPosition(UDim2.new(x, 0, ogy, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Bounce, 1, false)
		end	
	end
	
	local function update2()
		local tween = parent:TweenPosition(UDim2.new(x, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Bounce, 1, false)
		task.wait(1)
		parent.Visible = false
	end

	
	close.MouseButton1Click:Connect(update2)
	parent:GetPropertyChangedSignal("Visible"):Connect(update)
end

Local Script

mod = require(script.Parent.Parent:WaitForChild("Menus"))
mod.blur(script.Parent)
mod.tween(script.Parent, 0.246, 0.226, script.Parent:WaitForChild("Close"))

(mod.blur is a vaild function in the module. I just didnt show it since I don’t think it has anything to do with my problem.)

2 Likes

Are there any specific errors in the output? If so, could you show a screenshot of it or send in text. Have you tried using prints to see if the code in the update2 function continues to run?

3 Likes

Your code seems to work just fine:

Menus
local module = {}

function module.blur(parent)
	-- ...
end

function module.tween(parent, x, ogy, close)
	local function update()
		if parent.Visible == true then
			parent.Position = UDim2.new(x, 0, 1, 0)
			local tween = parent:TweenPosition(UDim2.new(x, 0, ogy, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Bounce, 1, false)
		end	
	end

	local function update2()
		local tween = parent:TweenPosition(UDim2.new(x, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Bounce, 1, false)
		task.wait(1)
		parent.Visible = false
	end


	close.MouseButton1Click:Connect(update2)
	parent:GetPropertyChangedSignal("Visible"):Connect(update)
end

return module
LocalScript
mod = require(script.Parent.Parent:WaitForChild("Menus"))
mod.blur(script.Parent)
mod.tween(script.Parent, 0.246, 0.226, script.Parent:WaitForChild("Close"))
3 Likes

There is 0 errors in output and it seems that update2() Isnt running. I’ll try deleting the instance and replacing it

Edit: It didn’t help.

2 Likes

Similar to “.activated” not working, isn’t it?

2 Likes

I posted an example using your exact code and it’s completely functional, as demonstrated in the video.

You’ll need to describe your issue in more detail and post other portions of your code and instance setup in order for us to diagnose it further.

1 Like

Well this is all the code associated. Ill try to include a video

2 Likes

Similar to “.activated” not working, isn’t it?

Maybe. I don’t really know.

2 Likes

Can you show the full local script?

2 Likes

I don’t think the rest is relevant but here is the full script(the other script that was it)

local module = {}
local TS = game:GetService("TweenService")

function module.blur(parent)
	local blur = game:GetService("Lighting"):WaitForChild("Blur")

	parent:GetPropertyChangedSignal("Visible"):Connect(function()
		if parent.Visible == true then
			print("visible")
			while blur.Size ~= 10 and parent.Visible == true do
				blur.Size += 1
				print("Changing blur... " .. blur.Size)
				task.wait(0.1)
			end
		else
			print("invisible")
			while blur.Size ~= 0 and parent.Visible == false do
				blur.Size -= 1
				print("Changing blur... " .. blur.Size)
				task.wait(0.1)
			end
		end
	end)
end

function module.tween(parent, x, ogy, close)
	local function update()
		if parent.Visible == true then
			parent.Position = UDim2.new(x, 0, 1, 0)
			local tween = parent:TweenPosition(UDim2.new(x, 0, ogy, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Bounce, 1, false)
		end	
	end
	
	local function update2()
		print("BEEM")
		local tween = parent:TweenPosition(UDim2.new(x, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Bounce, 1, false)
		task.wait(1)
		parent.Visible = false
	end
	
	
	close.MouseButton1Click:Connect(update2)
	parent:GetPropertyChangedSignal("Visible"):Connect(update)
end

return module
2 Likes

close.MouseButton1Down:Connect

2 Likes

When I added this I got this error:

Requested module experienced an error while loading

Oops, sorry. Revert that part.
Maybe your mouse is broken.
And add :activated too.

Just got the error

Requested module experienced an error while loading

Again.

I recommend he doesn’t use that module script. Just use a normal local script.

Copy the position of the gui when it’s opened then press CTRL + U to undo so the GUI goes back where it was hidden.

Paste that position in a text file, and copy the current GUI position again.

Then you can just use a boolean value like debounce. And tween the UI
EG:


debounce = false
script.Parent.MouseButton1Click:Connect(function()
   debounce = not debounce
   if debounce then
      script.Parent:TweenPosition(UDim2.new(xOpeningPos, 0, yOpeningPos, 0), "Out", "Bounce", 1, false)
   else
      script.Parent:TweenPosition(UDim2.new(xClosingPos, 0, yClosingPos, 0), "Out", "Bounce", 1, false)

end)

If module was used outside of clicking.

I recommend he doesn’t use that module script. Just use a normal local script.
Copy the position of the gui when it’s opened then press CTRL + U to undo so the GUI goes back where it was hidden.
Paste that position in a text file, and copy the current GUI position again.
Then you can just use a boolean value like debounce. And tween the UI
EG:

I’ll try out something similar

Edit: Didn’t work

Well it doesnt work for me and I have no idea why.

Deleted most code and replaced them. Now it works.

2 Likes