I want to make my projectile scale with magnitude. For example the closer the mouse position is to the gun the less force it takes but it still reaches it.
Ive tried searching around but i couldnt find anything.
Another thing is when i click the skybox my projectile bugs out so i want to add some sort of limit to how far the projectile could go
My Code:
Event.OnServerEvent:Connect(function(Player, MousePos)
local Duration = 1
local Direction = (MousePos - Pistol.FirePart.Position) / Duration
local Part = Instance.new("Part")
Part.Position = MousePos
Part.Parent = workspace
Part.Size = Vector3.new(2,2,2)
Part.Color = Color3.new(1, 0, 0.0156863)
Part.Transparency = 0.4
Part.CanCollide = false
Part.Anchored = true
local ShotSound = Sound:Clone()
ShotSound.Parent = Pistol.FirePart
ShotSound:Play()
local NewBullet = Bullet:Clone()
NewBullet.Position = Pistol.FirePart.Position
NewBullet.Parent = workspace
NewBullet.CanCollide = true
NewBullet.AssemblyLinearVelocity = Direction + Vector3.new(0, workspace.Gravity / 2 / Duration, 0)
NewBullet:SetNetworkOwner(nil)
ShotSound:Destroy()
end)
So i tried doing direction.magnitude but it didnt work.