I have a script that fires a bullet.(surprising) Only problem is its inconsistent and doesn’t detect hits against parts, and i have no idea why.
function cast (Start, endposition, velocity, original)
local Bullet = RS.Debris.Bullet:Clone()
local bv = Instance.new("BodyVelocity")
bv.Velocity = velocity
bv.Parent = Bullet
Bullet.Parent = game.Workspace
Bullet.Position = Start
Bullet.CanQuery = false
Bullet.CFrame = CFrame.new(Start, endposition) * CFrame.Angles(0,math.rad(90),0)
Shoot:FireServer(Start,endposition,velocity)
local BulletImpactLoop = nil
BulletImpactLoop = RunService.RenderStepped:Connect(function()
local hitcheck = game.Workspace:Raycast(Bullet.Position+-Bullet.CFrame.LookVector*2,Bullet.CFrame.LookVector*5)
if hitcheck then
if hitcheck.Instance.Parent:FindFirstChild("Humanoid") then
if original then
print("Server, blow him to smithereens, NOW!!!")
Hit:FireServer(hitcheck.Instance.Parent)
else
print("you cant damage the player with a bullet that isnt yours player silly~ Stop.")
end
end
Bullet:Destroy()
BulletImpactLoop:Disconnect()
print("Hit. Stop now.")
end
end)
game:GetService("Debris"):AddItem(Bullet,4)
task.spawn(function()task.wait(4)BulletImpactLoop:Disconnect()end)
end
And then a video:
Does anyone have a better way to do this reliably and consistently, or just another way entirely?
Any help would be appreciated, thank you.