Advertisement
Kaemi

wa

Feb 22nd, 2018
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.36 KB | None | 0 0
  1. function sandbox(var,func)
  2. local env = getfenv(func)
  3. local newenv = setmetatable({},{
  4. __index = function(self,k)
  5. if k=="script" then
  6. return var
  7. else
  8. return env[k]
  9. end
  10. end,
  11. })
  12. setfenv(func,newenv)
  13. return func
  14. end
  15. cors = {}
  16. mas = Instance.new("Model",game:GetService("Lighting"))
  17. Tool0 = Instance.new("Tool")
  18. Part1 = Instance.new("Part")
  19. SpecialMesh2 = Instance.new("SpecialMesh")
  20. Sound3 = Instance.new("Sound")
  21. LocalScript4 = Instance.new("LocalScript")
  22. Script5 = Instance.new("Script")
  23. Script6 = Instance.new("Script")
  24. NumberValue7 = Instance.new("NumberValue")
  25. Tool0.Name = "Railgun"
  26. Tool0.Parent = mas
  27. Tool0.TextureId = "http://www.roblox.com/asset/?id=79429068"
  28. Tool0.GripPos = Vector3.new(0, -0.75, 1.29999995)
  29. Tool0.ToolTip = "Railgun"
  30. Part1.Name = "Handle"
  31. Part1.Parent = Tool0
  32. Part1.BrickColor = BrickColor.new("Really black")
  33. Part1.Locked = true
  34. Part1.FormFactor = Enum.FormFactor.Custom
  35. Part1.Size = Vector3.new(0.5, 1.58000135, 4.71000051)
  36. Part1.CFrame = CFrame.new(-0.999999881, 0.0999954715, -1.00000012, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  37. Part1.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
  38. Part1.Position = Vector3.new(-0.999999881, 0.0999954715, -1.00000012)
  39. Part1.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
  40. SpecialMesh2.Parent = Part1
  41. SpecialMesh2.MeshId = "http://www.roblox.com/asset/?id=79429148"
  42. SpecialMesh2.Scale = Vector3.new(0.75, 0.75, 0.75)
  43. SpecialMesh2.TextureId = "http://www.roblox.com/asset/?id=79429114"
  44. SpecialMesh2.MeshType = Enum.MeshType.FileMesh
  45. SpecialMesh2.Scale = Vector3.new(0.75, 0.75, 0.75)
  46. Sound3.Parent = Part1
  47. Sound3.SoundId = "http://www.roblox.com/asset/?id=77170656"
  48. Sound3.Volume = 1
  49. LocalScript4.Parent = Tool0
  50. table.insert(cors,sandbox(LocalScript4,function()
  51. --Made by Stickmasterluke
  52.  
  53.  
  54. sp=script.Parent
  55. plr=game.Players.localPlayer
  56.  
  57.  
  58. damage=9999999999999999913376412809999999999999999999999999999999999999999999999999999999999999999999999
  59. firerate=0
  60. range=1500
  61. barreloffset=Vector3.new(0, 0.25, -1.7)
  62. windvec=Vector3.new(2,-1,1).unit
  63.  
  64. rate=1/30
  65. debris=game:GetService("Debris")
  66. equipped=false
  67. check=true
  68.  
  69. function tagHumanoid(humanoid)
  70. local creator_tag=Instance.new("ObjectValue")
  71. creator_tag.Value=game.Players.LocalPlayer
  72. creator_tag.Name="creator"
  73. debris:AddItem(creator,3)
  74. creator_tag.Parent=humanoid
  75. end
  76.  
  77. function checkintangible(hit)
  78. if hit and hit~=nil then
  79. if hit:IsDescendantOf(sp.Parent) or hit.Transparency>.8 or hit.Name=="Handle" or hit.Name=="Effect" or hit.Name=="Bullet" or hit.Name=="Laser" or string.lower(hit.Name)=="water" or hit.Name=="Rail" then
  80. return true
  81. end
  82. end
  83. return false
  84. end
  85.  
  86. function castray(startpos,vec,length,ignore,delayifhit)
  87. local hit,endpos2=game.Workspace:FindPartOnRay(Ray.new(startpos,vec*length),ignore)
  88. if hit~=nil then
  89. if checkintangible(hit) then
  90. if delayifhit then
  91. wait()
  92. end
  93. hit,endpos2=castray(endpos2+(vec*.01),vec,length-((startpos-endpos2).magnitude),ignore,delayifhit)
  94. end
  95. end
  96. return hit,endpos2
  97. end
  98.  
  99. function drawbeam(beamstart,beamend,clr,fadedelay)
  100. local dist=(beamstart-beamend).magnitude
  101. local laser=Instance.new("Part")
  102. laser.Name="Effect"
  103. laser.Anchored=true
  104. laser.CanCollide=false
  105. laser.Shape="Block"
  106. laser.formFactor="Custom"
  107. laser.Size=Vector3.new(.2,.2,.2)
  108. laser.Transparency=5
  109. laser.Material=Enum.Material.Plastic
  110. laser.Locked=true
  111. laser.TopSurface=0
  112. laser.BottomSurface=0
  113. laser.BrickColor=clr
  114. laser.CFrame=CFrame.new(beamend,beamstart)*CFrame.new(0,0,-dist/2)*CFrame.Angles(math.pi/2,0,0)
  115. local m=Instance.new("SpecialMesh")
  116. m.Scale=Vector3.new(2,dist*5,2)
  117. m.Parent=laser
  118. debris:AddItem(laser,fadedelay*3)
  119. laser.Parent=game.Workspace
  120. --wait(.25)
  121. local frames=fadedelay/rate
  122. for frame=1,frames do
  123. wait(rate)
  124. local percent=frame/frames
  125. --m.Scale=Vector3.new(1+(20*percent),dist*5,1+(20*percent))
  126. laser.CFrame=laser.CFrame+windvec*rate
  127. laser.Transparency=.5+(percent*.5)
  128. end
  129. wait(2)
  130. laser:remove()
  131. end
  132.  
  133. function onEquipped(mouse)
  134. equipped=true
  135. if mouse~=nil then
  136. mouse.Icon="rbxasset://textures\\GunCursor.png"
  137. mouse.Button1Down:connect(function()
  138. local he=sp.Parent:FindFirstChild("Head")
  139. local hu=sp.Parent:FindFirstChild("Humanoid")
  140. if check and he and hu and hu.Health>0 then
  141. check=false
  142. mouse.Icon="rbxasset://textures\\GunWaitCursor.png"
  143. local startpos=he.Position
  144. local vec=(mouse.Hit.p-startpos).unit
  145. local hit,endpos=castray(startpos,vec,range,sp.Parent,false)
  146. local fakevec=(endpos-(sp.Handle.CFrame*CFrame.new(barreloffset)).p).unit
  147. sp.PlaySound.Value=tick()
  148. local rail=Instance.new("Part")
  149. rail.Friction=1
  150. rail.Name="Rail"
  151. rail.Anchored=false
  152. rail.CanCollide=true
  153. rail.formFactor="Custom"
  154. rail.Size=Vector3.new(.6,.4,8)
  155. rail.TopSurface="Smooth"
  156. rail.BottomSurface="Smooth"
  157. rail.BrickColor=BrickColor.new("Dark stone grey")
  158. debris:AddItem(rail,10)
  159. if hit and hit~=nil then
  160. local h=hit.Parent:FindFirstChild("Humanoid")
  161. if h~=nil and h.Health>0 then
  162. tagHumanoid(h)
  163. h.Parent:BreakJoints()
  164. end
  165. if not hit.Anchored then
  166. rail.Velocity=fakevec*200
  167. hit.CFrame=hit.CFrame+Vector3.new(0,.1,0)
  168. end
  169. local newcf=CFrame.new(endpos,endpos+fakevec)*CFrame.new(0,0,(math.random()*(rail.Size.z-2))-((rail.Size.z-2)/2))
  170. rail.CFrame=newcf
  171. local w=Instance.new("Weld")
  172. w.Part0=hit
  173. w.Part1=rail
  174. w.C0=hit.CFrame:inverse()*newcf
  175. w.C1=newcf:inverse()*newcf
  176. w.Parent=rail
  177. local soundscript=sp.SoundScript:clone()
  178. soundscript.Parent=rail
  179. soundscript.Disabled=false
  180. rail.Parent=game.Workspace
  181. if not hit.Anchored then
  182. hit.Velocity=hit.Velocity+fakevec*50
  183. end
  184. else
  185. rail.CFrame=CFrame.new(endpos,endpos+fakevec)
  186. rail.Velocity=fakevec*300
  187. rail.Parent=game.Workspace
  188. end
  189. delay(0,function() --This is nessecery to fire multible shots at the same time. For those who don't know, delay() is a poor man's coroutine.
  190. drawbeam((sp.Handle.CFrame*CFrame.new(barreloffset)).p,endpos,BrickColor.new("Institutional white"),2)
  191. end)
  192. wait(firerate)
  193. mouse.Icon="rbxasset://textures\\GunCursor.png"
  194. check=true
  195. end
  196. end)
  197. end
  198. end
  199.  
  200. function onUnequipped()
  201. equipped=false
  202. end
  203.  
  204. sp.Equipped:connect(onEquipped)
  205. sp.Unequipped:connect(onUnequipped)
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212. end))
  213. Script5.Name = "SoundScript"
  214. Script5.Parent = Tool0
  215. Script5.Disabled = true
  216. table.insert(cors,sandbox(Script5,function()
  217. --Stickamsterluke
  218. --this script this made so that the sound is not played locally
  219.  
  220.  
  221. sp=script.Parent
  222.  
  223. local s=Instance.new("Sound")
  224. s.Volume=2
  225. s.SoundId="http://www.roblox.com/asset/?id=77170993"
  226. s.Looped=false
  227. s.PlayOnRemove=false
  228. s.Parent=sp
  229. wait()
  230. s:Play()
  231.  
  232.  
  233.  
  234. end))
  235. Script6.Parent = Tool0
  236. table.insert(cors,sandbox(Script6,function()
  237. --Stickamsterluke
  238. --this script this made so that the sound is not played locally
  239.  
  240.  
  241. sp=script.Parent
  242.  
  243.  
  244. wait(1)
  245.  
  246. sp.PlaySound.Changed:connect(function()
  247. sp.Handle.Sound:Play()
  248. end)
  249.  
  250.  
  251.  
  252. end))
  253. NumberValue7.Name = "PlaySound"
  254. NumberValue7.Parent = Tool0
  255. NumberValue7.Value = 1336154690.422
  256. for i,v in pairs(mas:GetChildren()) do
  257. v.Parent = game:GetService("Players").LocalPlayer.Backpack
  258. pcall(function() v:MakeJoints() end)
  259. end
  260. mas:Destroy()
  261. for i,v in pairs(cors) do
  262. spawn(function()
  263. pcall(v)
  264. end)
  265. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement