My projectile script shoots a shadow ball thingy to the mouse, the mousepos is fired over from a localscript. It works well but sometimes it just falls on your head? help appreciated.
https://gyazo.com/90441ec262916cbbd19e76cc27157d42
local shadow = game.ServerStorage.MAGICKS:WaitForChild("Shadow") local shadowDMG = 60 game.ReplicatedStorage.shadowService.OnServerEvent:Connect(function(player, mouse, origin) local character = player.Character local newShadow = shadow:Clone() newShadow.CFrame = character.HumanoidRootPart.CFrame local shadowVelocity = Instance.new("BodyForce") shadowVelocity.Force = (mouse.Position) shadowVelocity.Parent = newShadow newShadow.Parent = workspace local touchCon touchCon = newShadow.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then if hit.Parent.Name ~= player.Name then hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - shadowDMG if touchCon ~= nil then touchCon:Disconnect() end newShadow:Destroy() end end end) wait(4) if touchCon ~= nil then touchCon:Disconnect() end newShadow:Destroy() end)
The force of your shadowVelocity
should be the direction from either the character to the mouse position or the camera to the mouse position (your choice). This would be done like so...
local POWER = 10 local character = LocalPlayer.Character local force = (mouse.Hit.Position - character.PrimaryPart.Position).Unit * POWER
or
local POWER = 10 local camera = workspace.CurrentCamera local force = (mouse.Hit.Position - camera.CFrame.Position).Unit * POWER
The (pos1 - pos2).Unit
gets a unit vector that points in the direction of pos2 to pos1. This vector is very small, so to make it a usable force you would want to add a scalar (power) to it.