Throwing knife on mobile help

Hello everyone, for some context i am working on a game and in it i have a knife that you can throw, it threw a knife at the players Mouse.hit.p and it worked fine but today i was adding mobile support so players could throw on mobile devices and i tried many iterations and they suffered, so i decided i were to make a cursor in the middle of mobile player’s screen so when they press button knife would throw at where the cursor is pointing at, how would i go about making this?

I’m on mobile so I’ll just give you a basic explanation of what I’d do. The best course of action for this would most likely be to use a raycast, which can detect if it hit a player, and where it hit the player.

The next thing I would use would be the current camera of the player, as with this you know where and what direction to cast the ray in.

This code will cast a ray from the camera and detect where and what it hit

local camera = game.workspace.currentcamera
local camCFrame = camera.CFrame

-- Build a "RaycastParams" object
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
raycastParams.FilterDescendantsInstances = {workspace.Model}
raycastParams.IgnoreWater = true
 
-- Cast the ray
local part = workspace.Part
local raycastResult = workspace:Raycast(camCFrame.Position, camCFrame.lookVector, raycastParams)
 
-- Interpret the result
if raycastResult then
        local player = game.Players:GetPlayerFromCharacter(raycastResult.Instance)
	local position = raycastResult.Position
	if player ~= nil then
                print('hit player')
        end
end