Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Bullet is going to fast to register when it hits something?

Asked by 6 years ago

So I recently made a pistol and I think it turned our pretty well. However, if I crank the bullet's velocity up to 200 or above it won't register the bullet hitting something (a zombie) from a close range. Is there any way to fix this? These are the parts in the script where I believe the error is coming from

bullet.CFrame = char.Pistol.Barrel.CFrame
bullet.CFrame = CFrame.new(bullet.Position, target.p)   --bullet position = mouse position
bullet.BodyVelocity.Velocity = bullet.CFrame.lookVector * 200   --speed of bullet
...
...
...
bullet.Touched:connect(function(hit)
    local blood = game.Workspace.blood:Clone()
    local zombie = hit.Parent:FindFirstChild("Zombie")
    local humanoid = hit.Parent:FindFirstChild("Humanoid")
    local head = hit.Parent:FindFirstChild("Head")
    if (hit == head and zombie) then
        blood.Parent = hit
            if(humanoid) then
                blood:remove()
            end
        zombie:TakeDamage(100)
        bullet:Remove()
        wait(0.5)
        blood:Remove()
    elseif(zombie) then
        blood.Parent = hit
            if(humanoid) then
                blood:remove()
            end
        zombie:TakeDamage(16.67)
        bullet:Remove()
            wait(0.5)
        blood:Remove()
    elseif (hit ~= tool or hit ~= char or hit ~= humanoid) then
        bullet:remove()
    end
end)

I know the touch function is kinda weird but I'm new to this and it works so it's what I'm going with for now

0
Try printing if it actually runs the touched function User#20388 0 — 6y
1
use raycasting for your bullets it is way easier hellmatic 1523 — 6y
0
raycasting can make your bullet do instant damage (right when you click). You can lerp the bullets CFrame if you don't want instant damage awesomeipod 607 — 6y
0
ok ill try it out, thanks sonicfan0405 18 — 6y

Answer this question