How to make projectiles shoot at mouse position?

Hello people,
Just like the title says, how can i get the projectiles to shoot at mouse position because when i use mouse.Hit.p it shows the position relative to the world. Also I am using a tool and server events to pass the necessary information
Server Script (tool handler script):

tool.Activated:Connect(function()
	local pos
	
	mouseEvent.OnServerEvent:Connect(function(plr, mouseHit)
		print(mouseHit)
		pos = mouseHit
	end)
	
	
	local ball = ss.Projectiles.FireBall:Clone()
	local bv = Instance.new("BodyVelocity")	
	ball.CFrame = script.Parent.Handle.CFrame
	bv.Velocity = ball.CFrame.lookVector * speed
	bv.Parent = ball
	ball.Parent = game.Workspace.Projectiles
end)

Local Script:

local Character = Player.Character or Player.CharacterAdded:Wait()
local mouseEvent = game.ReplicatedStorage.Events.GetMousePosEvent
local debounce = false

Character.ChildAdded:Connect(function(NewChild)
	if NewChild:IsA("Tool") then
		if NewChild.Name == "Wand" then	
			debounce = true
			local mouse = Player:GetMouse()
			mouseEvent:FireServer(mouse.Hit.p)	
		end
	end
end)



Character.ChildRemoved:Connect(function(RemovedChild)
	if RemovedChild:IsA("Tool") then
		if RemovedChild.Name == "Wand" then
			debounce = false
		end
	end
end)

Ask me if anything is necessary, thx for the help!

1 Like

Try changing it to something like this:

ball.CFrame = CFrame.lookAt(script.Parent.Handle.Position, [MOUSE POSITION HERE])
2 Likes

I may be interpreting this wrong, but it seems like you want to make the projectiles spawn where the mouse actually is, instead of where it hits a part. In this case you’d have to use Workspace.CurrentCamera.Position and could then cast ray from that to the Mouse.Hit. Although I do not know how FOV would affect this.

hmmm…i want to make the projectiles spawn or start at the CFrame of the wand then fire them at mousePos, which @WlTTHY has done…thanks for the help though…