|
| 17 Jul 2014 01:38 PM |
bin = script.Parent dist = 80
function getHumans() for _, v in pairs(game.Players:GetChildren()) do if v.Character ~= nil and v.Character:FindFirstChild("Torso") ~= nil and v.Character:FindFirstChild("Humanoid") ~= nil and v.Character.Humanoid.Health > 0 then if (v.Character.Torso.Position - script.Parent.Shooter.Position).magnitude <= 80 then return v.Character.Torso end end end return nil end
function aim(targ) local dir = targ.Position - script.Parent.Barrel.Position dir = computeDirection(dir) local mag = (targ.Position - script.Parent.Barrel.Position).magnitude local spawnPos = script.Parent.Barrel.Position local pos = spawnPos + (dir * (math.ceil(mag)/2)) bin.Barrel.BodyGyro.cframe = CFrame.new(pos, pos + dir) local look = script.Parent.Shooter.CFrame.lookVector local p = Instance.new("Part") p.formFactor = "Symmetric" p.Size = Vector3.new(1,1,1) p.TopSurface = "Smooth" p.Shape = "Ball" p.BottomSurface = "Smooth" p.Name = "Bullet" p.BrickColor = BrickColor.new(26) pMesh = Instance.new("SpecialMesh") pMesh.MeshId = "http://www.roblox.com/asset/?id=101160425" pMesh.TextureId = "http://www.roblox.com/asset/?id=101159976" pMesh.Scale = Vector3.new(1, 1, 1) pMesh.Parent = p p.CFrame = script.Parent.Shooter.CFrame + (1.5*look) local b = Instance.new("BodyVelocity") b.velocity = (50*look) b.Parent = p p.Parent = workspace local sc = script.Damage:clone() sc.Disabled = false sc.Parent = p end
function computeDirection(vec) local lenSquared = vec.magnitude * vec.magnitude local invSqrt = 1 / math.sqrt(lenSquared) return Vector3.new(vec.x * invSqrt, vec.y * invSqrt, vec.z * invSqrt) end
while true do wait(0.1) local target = getHumans() if target ~= nil then aim(target) end end
--where do i put wait(5)? |
|
|
| Report Abuse |
|
| |