Advertisement
Roblox_Xploits

meep

Jun 24th, 2017
570
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. game:GetObjects("rbxassetid://881234702")[1].Parent=game.workspace
  2.  
  3. wait(0.3)
  4.  
  5.  
  6. function Shoot()
  7. while true do
  8. local laser = Instance.new("Part")
  9. laser.Name = "Laser"
  10. laser.FormFactor = Enum.FormFactor.Custom
  11. laser.TopSurface, laser.BottomSurface = 0, 0
  12. laser.Size = Vector3.new(0.2, 0.2, 0.2)
  13. laser.BrickColor = BrickColor.new("Crimson")
  14. laser.Anchored = true
  15. laser.CanCollide = false
  16. laser.Locked = true
  17. laser.CFrame = script.Parent.CFrame
  18. laser.Parent = game.Workspace
  19.  
  20. local maxDistance = 400
  21. local curDistance = 0
  22.  
  23. local stepDistance = 4
  24. local stepWait = 0
  25.  
  26. local currentPos = script.Parent.Position
  27. local currentNormal = game.workspace.LeFireFire.CFrame.lookVector
  28.  
  29. local function Step(overrideDistance)
  30.  
  31. -- Cast ray:
  32. local ray = Ray.new(currentPos, currentNormal * (overrideDistance or stepDistance))
  33. local hit, pos, norm = game.Workspace:FindPartOnRayWithIgnoreList(ray, {script.Parent})
  34.  
  35. -- Update laser position:
  36. laser.Size = Vector3.new(0.4, 0.4, (pos - currentPos).magnitude)
  37. laser.CFrame = CFrame.new(currentPos:lerp(pos, 0.5), pos)
  38.  
  39. local oldPos = currentPos
  40. currentPos = pos
  41.  
  42. if (hit) then
  43. -- r = d - 2(d DOT n)n
  44. -- Reflect:
  45. local reflect = (currentNormal - (2 * currentNormal:Dot(norm) * norm))
  46. currentNormal = reflect
  47. Step(stepDistance - (pos - oldPos).magnitude)
  48. return
  49. end
  50.  
  51. curDistance = (curDistance + (pos - oldPos).magnitude)
  52.  
  53. -- Apply fade effect to laser as it approaches max distance from < 75 studs:
  54. if (curDistance > (maxDistance - 75)) then
  55. local d = (curDistance - (maxDistance - 75)) / 75
  56. laser.Transparency = d
  57. end
  58.  
  59. -- Recurse if max distance not reached:
  60. if (curDistance < maxDistance) then
  61. wait(stepWait)
  62. Step()
  63. end
  64. end
  65.  
  66. Step()
  67.  
  68. -- Done! Destroy laser:
  69. laser:Destroy()
  70.  
  71. end
  72. end
  73. Shoot() -- Fire shot!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement