Advertisement
PeanutBrickle

Raygun

Jun 13th, 2015
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.23 KB | None | 0 0
  1. local tool=Instance.new("Tool",game.Players.LocalPlayer.Backpack)
  2. tool.GripForward = Vector3.new(0, 0, -1)
  3. tool.GripPos = Vector3.new(0, -0.1, 0.75)
  4. tool.GripRight = Vector3.new(1, 0, 0)
  5. tool.GripUp = Vector3.new(0,1,0)
  6. tool.TextureId = "http://www.roblox.com/asset?id=130093050"
  7.  
  8. tool.Name = "Ray Gun"
  9.  
  10.  
  11. local color = "Red"
  12.  
  13.  
  14. local handle=Instance.new("Part",tool)
  15. handle.Name="Handle"
  16. handle.Size=Vector3.new(1,1,1)
  17. handle.BrickColor = BrickColor.new(color)
  18. handle.Locked = true
  19. local mesh=Instance.new("SpecialMesh", handle)
  20. mesh.MeshType="FileMesh"
  21. mesh.MeshId="http://www.roblox.com/asset?id=130099641"
  22. mesh.Scale = Vector3.new(0.65, 0.65, 0.65)
  23.  
  24. local user
  25.  
  26.  
  27. mode = 1
  28.  
  29.  
  30.  
  31.  
  32. tool.Equipped:connect(function(mouse)
  33. user = tool.Parent
  34.  
  35. mouse.KeyDown:connect(function(k)
  36. if k == "q" then
  37. if mode == 1 then
  38. mode = 2
  39. color = "Lime green"
  40. handle.BrickColor = BrickColor.new(color)
  41. elseif mode == 2 then
  42. mode = 3
  43. color = "Really blue"
  44. handle.BrickColor = BrickColor.new(color)
  45. elseif mode == 3 then
  46. mode = 4
  47. color = "Bright pink"
  48. handle.BrickColor = BrickColor.new(color)
  49. elseif mode == 4 then
  50. color = "Teal"
  51. handle.BrickColor = BrickColor.new(color)
  52. mode = 1
  53. end
  54. elseif k == "z" then
  55. tool.GripUp = Vector3.new(tool.GripUp.x,tool.GripUp.y - 1 ,tool.GripUp.z)
  56. elseif k == "x" then
  57. tool.GripUp = Vector3.new(tool.GripUp.x,tool.GripUp.y + 1 ,tool.GripUp.z)
  58. end
  59. end)
  60.  
  61. mouse.Button1Down:connect(function()
  62. local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit*300)
  63. local hit, position = game.Workspace:FindPartOnRay(ray, user)
  64.  
  65. local humanoid = hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid")
  66.  
  67.  
  68. if mode == 1 then
  69. if humanoid then
  70. humanoid:TakeDamage(100)
  71. end
  72. elseif mode == 2 then
  73. if humanoid then
  74. humanoid:TakeDamage(-10)
  75. end
  76.  
  77. elseif mode == 3 then
  78. if humanoid then
  79. humanoid.WalkSpeed = 0
  80. humanoid.Parent.Torso.Transparency = 1
  81. humanoid.Parent.Head.Reflectance = 1
  82. humanoid.Parent.Head.Anchored = true
  83. humanoid.Parent.Animate.Disabled = true
  84. wait(0.5)
  85. humanoid.Parent:BreakJoints()
  86. humanoid.Parent.Torso.Transparency = 0
  87. humanoid.Parent.Head.Reflectance = 0
  88. humanoid.Parent.Head.Anchored = false
  89. humanoid.Parent.Animate.Disabled = false
  90. end
  91. elseif mode == 4 then
  92. if humanoid then
  93. local plr = game.Players:GetPlayerFromCharacter(humanoid.Parent)
  94. if plr then
  95. plr:remove()
  96. end
  97. end
  98. end
  99.  
  100.  
  101.  
  102.  
  103. local distance = (position - tool.Handle.CFrame.p).magnitude
  104. local rayPart = Instance.new("Part", user)
  105. rayPart.Name = "RayPart"
  106. rayPart.BrickColor = BrickColor.new(color)
  107. rayPart.Transparency = 0.6
  108. rayPart.Anchored = true
  109. rayPart.CanCollide = false
  110. rayPart.TopSurface = Enum.SurfaceType.Smooth
  111. rayPart.BottomSurface = Enum.SurfaceType.Smooth
  112. rayPart.formFactor = Enum.FormFactor.Custom
  113. rayPart.Size = Vector3.new(0.3, 0.3, distance)
  114. rayPart.CFrame = CFrame.new(position, tool.Handle.CFrame.p) * CFrame.new(0, 0, -distance/2)
  115.  
  116. game.Debris:AddItem(rayPart, 0.1)
  117. end)
  118. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement