I am trying to make a gun that when it shoots, it shoots a bullet that slowly falls towards the ground that farther it goes. Here is what I have so far but it does not dip, and when turning, it acts strange. You just put this script and parent it to a tool and it will function.
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local Run = game:GetService("RunService")
local function CalculateLandingPoint(start,velocity,char)
velocity = Vector3.new(0,0,velocity)
local direction = start.LookVector * velocity
local startTime = tick()
local spos = start.Position
while wait() do
if tick()-startTime >= 3 then print("Unable to find object") break end
local dt = Run.RenderStepped:Wait()
local ray = Ray.new(spos,direction)
local hit,pos = workspace:FindPartOnRayWithIgnoreList(ray,{char})
if hit then
print(pos)
break
else
velocity = velocity-(Vector3.new(0,workspace.Gravity,0) * dt)
direction = start.LookVector * velocity
spos = pos
local part = Instance.new("Part")
part.Size = Vector3.new(1,1,1)
part.Anchored = true
part.CanCollide = false
part.Position = spos
part.Parent = workspace
end
end
end
mouse.Button1Down:connect(function()
local RunService = game:GetService("RunService")
CalculateLandingPoint(plr.Character.PrimaryPart.CFrame,2,plr.Character)
end)```