The title might be a bit confusing so i will provide a demonstration:
the blue line is meant to be the bullet trayectory
this is the codei have so far:
local ignore = {plr.Character}
local params = RaycastParams.new()
params.FilterDescendantsInstances = ignore
params.FilterType = Enum.RaycastFilterType.Blacklist
local connection
connection = run.Heartbeat:Connect(function(dt)
local hum
local hat
local newpos = bullet.CFrame.LookVector * 100
local oldpos = bullet.Position
local hite
for i, v in pairs(bullet:GetChildren()) do
if v:IsA("Attachment") and v.Name == "detector" then
local oldpos = v.WorldPosition
local newpos = v.WorldCFrame.LookVector * 100
newpos = newpos - (Vector3.new(0, workspace.Gravity, 0) * dt)
oldpos = oldpos + newpos * dt
local hit = game.Workspace:Raycast(oldpos, newpos, params)
hite = hit
if hit then
if hit.Instance.Parent:FindFirstChild("Humanoid") then
hum = hit.Instance.Parent:FindFirstChild("Humanoid")
else
--print("rd")
hat = true
end
end
end
end
if hum == nil then
newpos = newpos - (Vector3.new(0, workspace.Gravity, 0) * dt)
oldpos = oldpos + newpos * dt
bullet.Position = oldpos
bullet.CFrame = CFrame.new(oldpos, newpos)
elseif hat == true then
local norm = hite.Normal
local reflect = (newpos - (2 * newpos:Dot(norm) * norm))
newpos = reflect
oldpos = oldpos + newpos * dt
bullet.CFrame = CFrame.new(oldpos, newpos)
hat = false
else
connection:Disconnect()
bullet:Destroy()
end
end)