Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MaxDistance = 512
- Tool = script.Parent
- TouchDamage = 99
- DirectDamage = 99
- function fireLaser(pos, target, obj)
- local part = Instance.new("Part")
- part.Anchored = true
- part.CanCollide = false
- part.formFactor = "Symmetric"
- part.TopSurface = 0
- part.BottomSurface = 0
- part.BrickColor = BrickColor.new("Institutional white")
- part.Transparency = 0.5
- part.Name = "Laser Shot"
- part.Locked = true
- part.Size = Vector3.new(1,1,(pos - obj.Position).magnitude)
- part.CFrame = CFrame.new(((obj.Position + pos)/2) + 1 * (pos - obj.Position).unit, pos)
- local mesh = Instance.new("BlockMesh")
- mesh.Scale = Vector3.new(3,3,1)
- mesh.Parent = part
- part.Parent = workspace
- --Optional: Laser will damage others than the target.
- --part.Touched:connect(onTouch)
- local h = getHumanoid(target.Parent)
- local player = game.Players:findFirstChild(Tool.Parent.Name)
- if player ~= nil and h ~= nil and target.Parent ~= Tool.Parent then
- tagHumanoid(h, player)
- h:takeDamage(DirectDamage)
- wait(0.05)
- untagHumanoid(h)
- elseif player ~= nil and h==nil and target.Parent ~= Tool.Parent then
- if target:getMass() <= 216 then
- burn(target, part)
- end
- else
- getTarget(pos)
- end
- for v=1, 10 do
- part.Transparency = 0.1 * v
- wait(0.05)
- end
- part:remove()
- end
- function burn(obj, laser)
- print 'damaged'
- end
- function getTarget(pos)
- local child = workspace:getChildren()
- for i,v in pairs(child) do
- local h = getHumanoid(v)
- if h ~= nil and v ~= Tool.Parent then
- local torso = v:findFirstChild("Torso")
- if torso ~= nil then
- if (torso.Position - pos).magnitude <= 3 then
- local player = game.Players:findFirstChild(Tool.Parent.Name)
- if player ~= nil then
- tagHumanoid(h, player)
- end
- h:takeDamage(DirectDamage)
- wait(0.05)
- untagHumanoid(h)
- end
- end
- end
- end
- end
- function getHumanoid(obj)
- local child = obj:getChildren()
- for i=1, #child do
- if child[i].className == "Humanoid" then
- return child[i]
- end
- end
- return nil
- end
- db = false
- function onTouch(hit)
- if db then return end
- db = true
- if hit.Parent ~= Tool.Parent then
- local h = getHumanoid(hit.Parent)
- if h ~= nil then
- local player = game.Players:findFirstChild(Tool.Parent.Name)
- if player ~= nil then
- tagHumanoid(h, player)
- end
- h:takeDamage(TouchDamage)
- wait(0.1)
- untagHumanoid(h)
- end
- end
- wait(0.9)
- db = false
- end
- function tagHumanoid(humanoid, player)
- local creator_tag = Instance.new("ObjectValue")
- creator_tag.Value = player
- creator_tag.Name = "creator"
- creator_tag.Parent = humanoid
- end
- function untagHumanoid(humanoid)
- if humanoid ~= nil then
- local tag = humanoid:findFirstChild("creator")
- if tag ~= nil then
- tag.Parent = nil
- end
- end
- end
- enabled = true
- function onActivated(mouse)
- if not enabled or mouse.Target == nil then return end
- enabled = false
- local handle = Tool:findFirstChild("Particle")
- local human = Tool.Parent:findFirstChild("Humanoid")
- if handle ~= nil and human ~= nil then
- if (handle.Position - human.TargetPoint).magnitude <= MaxDistance then
- script.Parent.Closed1.Transparency = 1
- script.Parent.Closed2.Transparency = 1
- script.Parent.Open1.Transparency = 0
- script.Parent.Open2.Transparency = 0
- script.Parent.Eye2.Transparency = 1
- script.Parent.FirePart.Fire.Enabled = true
- script.Parent.Particle.ParticleEmitter.Enabled = true
- enabled = true
- wait(1)
- script.Parent.Eye2.Transparency = 0
- script.Parent.FirePart.Fire.Enabled = false
- script.Parent.Closed1.Transparency = 0
- script.Parent.Closed2.Transparency = 0
- script.Parent.Open1.Transparency = 1
- script.Parent.Open2.Transparency = 1
- script.Parent.Particle.ParticleEmitter.Enabled = false
- fireLaser(human.TargetPoint, mouse.Target, handle)
- end
- end
- end
- mouseabled = true
- function onButton1Down(mouse)
- if not mouseabled or mouse.Target == nil then return end
- mouseabled = false
- mouse.Icon = "rbxasset://textures/GunWaitCursor.png"
- wait(0.5)
- mouseabled = true
- mouse.Icon = "rbxasset://textures/GunCursor.png"
- end
- zoom = false
- function onKeyDown(key)
- key:lower()
- if key == "q" then
- if not zoom then
- zoom = true
- local obj = Instance.new("Part")
- obj.Parent = Tool.Parent
- obj.Size = Vector3.new(1,1,1)
- obj.Transparency = 1
- obj.CanCollide = false
- obj.Anchored = true
- obj.Name = "Zoom"
- obj.CFrame = CFrame.new(Tool.Parent.Humanoid.TargetPoint)
- cam = workspace.CurrentCamera:Clone()
- cam.Parent = workspace
- workspace.CurrentCamera.CameraSubject = obj
- workspace.CurrentCamera.CameraType = 4
- else
- zoom = false
- local check = Tool.Parent:findFirstChild("Zoom")
- if check ~= nil then
- check:remove()
- end
- workspace.CurrentCamera.CameraSubject = Tool.Parent.Humanoid
- workspace.CurrentCamera:Remove()
- workspace.CurrentCamera = cam
- end
- end
- end
- function onSelected(mouse)
- connection = script.Parent.Activated:connect(function() onActivated(mouse) end)
- mouse.KeyDown:connect(onKeyDown)
- mouse.Button1Down:connect(function() onButton1Down(mouse) end)
- mouse.Icon = "rbxasset://textures/GunCursor.png"
- end
- function onDeselected()
- connection:disconnect()
- end
- script.Parent.Equipped:connect(onSelected)
- script.Parent.Unequipped:connect(onDeselected)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement