Ball shooting where mouse isn't working as intended

I mean I should have known this was going to happen. I have 2 scripts that talk to each other via remote event and create a ball where the player’s mouse position is. I wanted it to like shoo out wherever the mouse is facing.

What’s happening:
robloxapp-20220206-0943497.wmv (661.6 KB)

Local script, located inside the tool:

local player = game.Players.LocalPlayer

local mouse = player:GetMouse()


local event = game.ReplicatedStorage.throw

local canshoot = true

local tool = script.Parent


function OnActivation()
	local hit = mouse.Hit

if canshoot == true then
	canshoot = false
	print('Activation works')
		event:FireServer(hit)



	wait()
	canshoot = true

end
end


tool.Activated:Connect(OnActivation)

Server script, located in serverscriptservice:

local storage = game.ReplicatedStorage

local event = storage.throw



local function onActivation(player, hit)


	

	local ball = Instance.new("Part")
	ball.Shape = Enum.PartType.Ball
	ball.Color = Color3.new(0.133333, 0.133333, 0.133333)
	ball.Size = Vector3.new(2,2,2)
	ball.Material = Enum.Material.Grass
	ball.CanCollide = false




	ball.CFrame = hit

	ball.Parent = game.Workspace
	local Velocity = Instance.new("BodyVelocity")

	Velocity.maxForce = Vector3.new(math.huge, math.huge, math.huge) 
	Velocity.Velocity = ball.CFrame.lookVector * 30


	Velocity.Parent = ball

end


event.OnServerEvent:Connect(onActivation)

You have to do mouse.Hit.Position not just mouse.Hit also I recommend not using roblox’s built in video because you have to download the file.

Ya sorry about that im not sure how to post videos otherwise
Also when i do position, or p, i get this error message:
ServerScriptService.throws:22: invalid argument #3 (CFrame expected, got Vector3)

because mouse.Hit is cframe and mouse.Hit.p is position so

ball.Position = hit

That is in the original code…


What are you exactly trying to make? A projectile like a gun or what? Because it seems you’re setting the ball to the mouse’s position.

You need to move the projectile to the mouse’s cursor not teleport the projectile to the mouse’s cursor.