Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function snapToTorso(pos)
- local list = game.Workspace:children()
- local torso = nil
- local dist = 100
- local temp = nil
- local human = nil
- local temp2 = nil
- for x = 1, #list do
- temp2 = list[x]
- if (temp2.className == "Model") and (temp2 ~= script.Parent) then
- temp = temp2:findFirstChild("Torso")
- human = temp2:findFirstChild("Humanoid")
- if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
- if (temp.Position - pos).magnitude < dist then
- torso = temp
- dist = (temp.Position - pos).magnitude
- annihilate()
- end
- end
- end
- end
- return torso
- end
- function annihilate(gun,targ)
- pcall(function() p:remove() end)
- p = Instance.new("Part")
- p.BrickColor = BrickColor.new(21)
- p.Anchored = true
- p.CanCollide = false
- p.formFactor = "Plate"
- p.Size = Vector3.new(1,0.4,1)
- p.TopSurface = "Smooth"
- p.BottomSurface = "Smooth"
- local sm = Instance.new("SpecialMesh")
- sm.MeshType = "Sphere"
- sm.Parent = p
- local mag = (gun.Position - targ).magnitude
- local aim = CFrame.new(gun.Position,targ)
- p.CFrame = aim + (aim.lookVector * (mag / 2))
- sm.Scale = Vector3.new(0.2,0.2,mag )
- p.Parent = workspace
- coroutine.resume(coroutine.create(function()
- wait(0.3)
- pcall(function() p:remove() end)
- end))
- end
- laser(script.Parent.Shooter,torso)
- local ex = Instance.new("Explosion")
- ex.Position = torso
- ex.BlastRadius = 3
- ex.Parent = workspace
- end)
- end)
Add Comment
Please, Sign In to add comment