Mobile support for mouse tracking ability

I am making an ability that lets you shoot a ball that one shots whoever it touches, and it tweens to the mouse, how would I make a mobile version of this?

local cooldown = 20
local active = false
local oncd = false
local equipped = false

script.Parent.AbilityEvent.OnServerEvent:Connect(function(plr, mouse)
	if equipped == true then
	if active == false and oncd == false then
		active = true
		script.Parent.Handle["magic attack sound"]:Play()
		local char = plr.Character
		local hrp = char:WaitForChild("HumanoidRootPart")
		local cf = hrp.CFrame
		local lv = cf.LookVector
		local part = Instance.new("Part")
			part.CFrame = hrp.CFrame + hrp.CFrame.LookVector * 5
		part.Anchored = true
		part.BrickColor = BrickColor.new("Hot pink")
		part.Material = "Neon"
		part.Shape = "Ball"
		part.Size = Vector3.new(4,4,4)
		part.CanCollide = false
		part.Parent = workspace
		part.Touched:Connect(function(hit)
			if hit.Parent:FindFirstChild("Humanoid") then
				hit.Parent:BreakJoints()
			end
		end)
		
		local useTime = (hrp.Position - mouse).Magnitude / 100
		
		local ts = game:GetService("TweenService")
		local tweenInfo = TweenInfo.new(useTime, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
		local goal = {Position = mouse}
		local tween = ts:Create(part,tweenInfo,goal)
		
		tween:Play()
		
		wait(useTime)
		part:Destroy()
		active = false
		oncd = true
		wait(cooldown)
		oncd = false
	end
	end
end)

script.Parent.Equipped:Connect(function()
	equipped = true
end)

script.Parent.Unequipped:Connect(function()
	equipped = false
end)
1 Like