How to Return a Boolean value for GuiButton being Pressed

Okay, I wish to return a bool on whether a button has been pressed or not. I don’t think Roblox has a built in method for this, so I was wondering if there was a function something I could use. I was trying to make my game available for mobile, so I’m slightly new to that system so any help will be appreciated.

if UIS.TouchEnabled and not UIS.KeyboardEnabled and not UIS.MouseEnabled and not UIS.GamepadEnabled and not GuiService:IsTenFootInterface() then
					for k, n in pairs(mobileBloxPatterns) do
						if n == Vector2.new(v.Position.Y, v.Position.Z) then
						if ((script.Parent.Effect.ControllerR.Center.Selected)) == false then -- here, what do I use instead of .selected?
							checked[tablelength(checked) + 1] = v
						else
							local checkCheck = nil
							for c, g in pairs(checked) do
								if g == v then
									checkCheck = g
								end
							end
							if script.Parent.Effect.ControllerR.Center.Selected == true and checkCheck ~= nil then -- it's here too
								local Shard1 = game.ReplicatedStorage.BloxShard:Clone()
								local force1 = Instance.new("BodyVelocity")
								force1.Parent = Shard1
								force1.Velocity = Vector3.new(10,-25,-5)
								Shard1.Color = v.Color
								Shard1.CFrame = v.CFrame
								Shard1.Parent = workspace.Base.ShardEffects
								local Shard2 = game.ReplicatedStorage.BloxShard:Clone()
								local force2 = Instance.new("BodyVelocity")
								force2.Parent = Shard2
								force2.Velocity = Vector3.new(10,-25,5)
								Shard2.Color = v.Color
								Shard2.CFrame = v.CFrame
								Shard2.Parent = workspace.Base.ShardEffects
								if v.Position.X < -21 then
									game.Players.LocalPlayer.CurrentPoints.Value += 12
								else
									game.Players.LocalPlayer.CurrentPoints.Value += math.floor(((v.Position.X * -1) - 11) + 2)
								end
								
								
								local StatusThing = game.Players.LocalPlayer.PlayerGui.Effect.EnergyBar.Status
								if v.Position.X < -21 then
									StatusThing.Text = "Perfect"
								elseif v.Position.X >= -21 and v.Position.X <= -17 then
									StatusThing.Text = "Good"
								elseif v.Position.X >= -13 then
									StatusThing.Text = "Awful"
								else
									StatusThing.Text = ""
								end
								
								
								v:Destroy()
								Energy.Value += 5
								if Energy.Value > 500 then Energy.Value = 500 end
							end
						end
					end
					end
				else

Thank you for your time, and thanks in advance for any help!

I dont use such a function/event, because we can simply use prints. If there is something printed it means that the GUI was fired

Yes but I can’t use a print() to obtain a boolean value out of.

what do u want to get out of it? Didnt u say u only want to know when Gui is activated/pressed?

Yes, I am wanting to use a line of code to obtain a boolean value of whether the GuiButton is being pressed.

Okay, I just decided that there wasn’t a really good way to approach this, so I made a button manager that would toggle boolean values based on whether that mutton was pressed or let go.

local RunService = game:GetService("RunService")
local Heartbeat = RunService.Heartbeat
local UIS = game:GetService("UserInputService")
local GuiService = game:GetService("GuiService")

local ControllerR = script.Parent.Effect.ControllerR
local ControllerL = script.Parent.Effect.ControllerL
local mobileBloxPatterns = {
	[script.Parent.Effect.ControllerR.Center] = Vector2.new(7,0),
	[script.Parent.Effect.ControllerR.Up1] = Vector2.new(10,0),
	[script.Parent.Effect.ControllerR.Left1] = Vector2.new(7,3),
	[script.Parent.Effect.ControllerR.Down1] = Vector2.new(4,0),
	[script.Parent.Effect.ControllerR.Right1] = Vector2.new(7,-3),
	[script.Parent.Effect.ControllerR.Up2] = Vector2.new(10,3),
	[script.Parent.Effect.ControllerR.Left2] = Vector2.new(4,3),
	[script.Parent.Effect.ControllerR.Right2] = Vector2.new(10,-3),
	[script.Parent.Effect.ControllerR.Down2] = Vector2.new(4,-3),
	[script.Parent.Effect.ControllerR.Farther] = Vector2.new(7,-7),
	[script.Parent.Effect.ControllerL.Center] = Vector2.new(7,0),
	[script.Parent.Effect.ControllerL.Up1] = Vector2.new(10,0),
	[script.Parent.Effect.ControllerL.Left1] = Vector2.new(7,3),
	[script.Parent.Effect.ControllerL.Down1] = Vector2.new(4,0),
	[script.Parent.Effect.ControllerL.Right1] = Vector2.new(7,-3),
	[script.Parent.Effect.ControllerL.Up2] = Vector2.new(10,3),
	[script.Parent.Effect.ControllerL.Left2] = Vector2.new(4,3),
	[script.Parent.Effect.ControllerL.Right2] = Vector2.new(10,-3),
	[script.Parent.Effect.ControllerL.Down2] = Vector2.new(4,-3),
	[script.Parent.Effect.ControllerL.FartherQ] = Vector2.new(7,7)
}

if UIS.TouchEnabled and not UIS.KeyboardEnabled and not UIS.MouseEnabled and not UIS.GamepadEnabled and not GuiService:IsTenFootInterface() then --mobile check
	ControllerR.Visible = true
	ControllerL.Visible = true
	script.Parent.Menu.Currency.Visible = false
	script.Parent.Menu.Shop.Visible = false
	script.Parent.Menu.Background.MobileExtras.Visible = true
end
	
for i, v in pairs(ControllerR:GetChildren()) do
	if script:FindFirstChild(v.Name) == nil then
		local newValue = Instance.new("BoolValue", script)
		newValue.Name = v.Name
		local tied = Instance.new("ObjectValue", newValue)
		tied.Name = "Origin"
		tied.Value = v
	end
end
for i, v in pairs(ControllerL:GetChildren()) do
	if script:FindFirstChild(v.Name) == nil then
		local newValue = Instance.new("BoolValue", script)
		newValue.Name = v.Name
		local tied = Instance.new("ObjectValue", newValue)
		tied.Name = "Origin"
		tied.Value = v
	end
end


--Right Controller Segment
ControllerR.Center.MouseButton1Down:Connect(function()script:FindFirstChild("Center").Value = true end)
ControllerR.Up1.MouseButton1Down:Connect(function()script:FindFirstChild("Up1").Value = true end)
ControllerR.Up2.MouseButton1Down:Connect(function()script:FindFirstChild("Up2").Value = true end)
ControllerR.Left1.MouseButton1Down:Connect(function()script:FindFirstChild("Left1").Value = true end)
ControllerR.Left2.MouseButton1Down:Connect(function()script:FindFirstChild("Left2").Value = true end)
ControllerR.Right1.MouseButton1Down:Connect(function()script:FindFirstChild("Right1").Value = true end)
ControllerR.Right2.MouseButton1Down:Connect(function()script:FindFirstChild("Right2").Value = true end)
ControllerR.Down1.MouseButton1Down:Connect(function()script:FindFirstChild("Down1").Value = true end)
ControllerR.Down2.MouseButton1Down:Connect(function()script:FindFirstChild("Down2").Value = true end)
ControllerR.Farther.MouseButton1Down:Connect(function()script:FindFirstChild("Farther").Value = true end)

ControllerR.Center.MouseButton1Up:Connect(function()script:FindFirstChild("Center").Value = false end)
ControllerR.Up1.MouseButton1Up:Connect(function()script:FindFirstChild("Up1").Value = false end)
ControllerR.Up2.MouseButton1Up:Connect(function()script:FindFirstChild("Up2").Value = false end)
ControllerR.Left1.MouseButton1Up:Connect(function()script:FindFirstChild("Left1").Value = false end)
ControllerR.Left2.MouseButton1Up:Connect(function()script:FindFirstChild("Left2").Value = false end)
ControllerR.Right1.MouseButton1Up:Connect(function()script:FindFirstChild("Right1").Value = false end)
ControllerR.Right2.MouseButton1Up:Connect(function()script:FindFirstChild("Right2").Value = false end)
ControllerR.Down1.MouseButton1Up:Connect(function()script:FindFirstChild("Down1").Value = false end)
ControllerR.Down2.MouseButton1Up:Connect(function()script:FindFirstChild("Down2").Value = false end)
ControllerR.Farther.MouseButton1Up:Connect(function()script:FindFirstChild("Farther").Value = false end)


--Left Controller Segment
ControllerL.Center.MouseButton1Down:Connect(function()script:FindFirstChild("Center").Value = true end)
ControllerL.Up1.MouseButton1Down:Connect(function()script:FindFirstChild("Up1").Value = true end)
ControllerL.Up2.MouseButton1Down:Connect(function()script:FindFirstChild("Up2").Value = true end)
ControllerL.Left1.MouseButton1Down:Connect(function()script:FindFirstChild("Left1").Value = true end)
ControllerL.Left2.MouseButton1Down:Connect(function()script:FindFirstChild("Left2").Value = true end)
ControllerL.Right1.MouseButton1Down:Connect(function()script:FindFirstChild("Right1").Value = true end)
ControllerL.Right2.MouseButton1Down:Connect(function()script:FindFirstChild("Right2").Value = true end)
ControllerL.Down1.MouseButton1Down:Connect(function()script:FindFirstChild("Down1").Value = true end)
ControllerL.Down2.MouseButton1Down:Connect(function()script:FindFirstChild("Down2").Value = true end)
ControllerL.FartherQ.MouseButton1Down:Connect(function()script:FindFirstChild("FartherQ").Value = true end)

ControllerL.Center.MouseButton1Up:Connect(function()script:FindFirstChild("Center").Value = false end)
ControllerL.Up1.MouseButton1Up:Connect(function()script:FindFirstChild("Up1").Value = false end)
ControllerL.Up2.MouseButton1Up:Connect(function()script:FindFirstChild("Up2").Value = false end)
ControllerL.Left1.MouseButton1Up:Connect(function()script:FindFirstChild("Left1").Value = false end)
ControllerL.Left2.MouseButton1Up:Connect(function()script:FindFirstChild("Left2").Value = false end)
ControllerL.Right1.MouseButton1Up:Connect(function()script:FindFirstChild("Right1").Value = false end)
ControllerL.Right2.MouseButton1Up:Connect(function()script:FindFirstChild("Right2").Value = false end)
ControllerL.Down1.MouseButton1Up:Connect(function()script:FindFirstChild("Down1").Value = false end)
ControllerL.Down2.MouseButton1Up:Connect(function()script:FindFirstChild("Down2").Value = false end)
ControllerL.FartherQ.MouseButton1Up:Connect(function()script:FindFirstChild("FartherQ").Value = false end)

This is very long and repetitive, but it gets the job done.