I have a GUI that I want to run two functions: Change the border color and make another GUI visible. Although it runs the first function, It won't run the second. This is the script:
script.Parent.MouseButton1Click:Connect(function() script.Parent.BorderColor3=Color3.new(0,0,0) end) script.Parent.MouseButton2Click:Connect(function() script.Parent.BorderColor3=Color3.new(255,255,255) script.Parent.Parent.Parent.File.Visible=true end) --File is a frame under a ScreenGui
local counter = 0 -- clicked 0 times right now... script.Parent.MouseButton1Click:Connect(function() counter = counter + 1 script.Parent.BorderColor3 = Color3.fromRGB(0,0,0) if counter == 2 then script.Parent.BorderColor3=Color3.fromRGB(255,255,255) script.Parent.Parent.Parent.File.Visible=true end end) --File is a frame under a ScreenGui
local debounce = true script.Parent.MouseButton1Click:Connect(function() if debounce == true then debounce = false script.Parent.BorderColor3=Color3.new(0,0,0) end end) script.Parent.MouseButton2Click:Connect(function() if debounce == false then debounce = true script.Parent.BorderColor3=Color3.new(255,255,255) script.Parent.Parent.Parent.File.Visible=true end end)
From what I'm understanding, the first function is playing, while the second is not. The cause of that is because every time the user registers the click, it'll count at MouseButton1Click. To combat this, I used a simple debounce so every time you click it'll rotate between the first and second function. Hopefully this works for you!