I am trying to remake some old guns from scratch and when I finished it the bullets don’t damage the NPC when its close. This is really annoying because I am using these guns for a zombie game and when the zombies are close it is impossible to kill them. If anyone can tell me whats wrong with the script that would be really good.
Example: https://gyazo.com/a0b11023799a6344df9b0d6730736071
Script:
Tool = script.Parent
Accuracy = 25
Muzzles = {
"http://www.roblox.com/asset/?id=131435802",
"http://www.roblox.com/asset/?id=131435817",
"http://www.roblox.com/asset/?id=131435825",
}
Tool.Shoot.OnServerEvent:Connect(function(vPlayer,lookAt)
local Flash = coroutine.create(function()
Tool.Muzzle.Flash.Flash.Image = Muzzles[math.random(1,#Muzzles)]
Tool.Muzzle.Flash.Flash.Visible = true
wait(0.1)
Tool.Muzzle.Flash.Flash.Visible = false
end)
coroutine.resume(Flash)
Tool.Fire:Play()
local missile = Instance.new("Part")
missile.Size = Vector3.new(1,1,1)
missile.Shape = 1
missile.BottomSurface = 0
missile.TopSurface = 0
missile.Name = "Bullet"
missile.Elasticity = 0
missile.Reflectance = .1
missile.Friction = .3
missile.CanCollide = false
missile.Parent = Tool
missile.CFrame = Tool.Barrel.CFrame
missile.Velocity = lookAt * 467 + Vector3.new(math.random(-Accuracy, Accuracy), math.random(-Accuracy, Accuracy), math.random(-Accuracy, Accuracy))
mesh = Tool.Mesh:Clone()
mesh.Parent = missile
local fly = Instance.new("BodyForce",missile)
fly.Force = Vector3.new(0,missile:GetMass()*196.2,0)
game.Debris:AddItem(missile,10)
wait()
missile.Touched:Connect(function(hit)
wait(0.25)
missile:remove()
end)
local new_script = script.Parent.Paintball:clone()
new_script.Disabled = false
new_script.Parent = missile
local creator_tag = Instance.new("ObjectValue")
creator_tag.Value = vPlayer
creator_tag.Name = "creator"
creator_tag.Parent = missile
end)