Script doesnt work on mobile

This script is one of 3 scripts being used this script currently tells the other 2 scripts when to pick up and to drop/throw a part, It worked before but this is the current script I changed it to and it doesnt work. I am assuming the issue revolves around the “if function onButtonPress()” part since it was different before. Is there anyway to make this work, I am trying to use “onButtonPress()” to make it mobile compatible

Previously, I’ve had the script so that where it says “if function onButtonPress() then” would say “if input.KeyCode == Enum.KeyCode.F then” and that seemed to work. I’m trying to use “function onButtonPress()” to make it mobile compatible but hasnt worked so far.

I’ve tried using both in one script by doing “if input.KeyCode == Enum.KeyCode.F or function onButtonPress() then” but that didnt work either.

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:wait()
local uis = game:GetService("UserInputService")
local hum = char:WaitForChild("Humanoid")
local anim = hum:LoadAnimation(script.GrabBlockAnim)
local CanGrabBlock = true
local contextActionService = game:GetService("ContextActionService")

local function Block(plr, block)
	if CanGrabBlock == true then 
		CanGrabBlock = false
		game.ReplicatedStorage.TakeBlock:FireServer(plr, block)
		uis.InputBegan:Connect(function(input, GameprocessedEvent)
			if function onButtonPress() then
				game.ReplicatedStorage.ThrowBlock:FireServer(plr, block)
				CanGrabBlock = true

local mobilebutton = contextActionService:BindAction("ThrowBlock",onButtonPress(),true,"f")```

Surprised no one has responded to this yet

Try making the onButtonPress function an actual function and not an if statement? Also be sure to add print statements as well for debugging