hawoody

Blue laser gun

Apr 15th, 2018
2,396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.74 KB | None | 0 0
  1. --Converted with ttyyuu12345's model to script plugin v4
  2. function sandbox(var,func)
  3. local env = getfenv(func)
  4. local newenv = setmetatable({},{
  5. __index = function(self,k)
  6. if k=="script" then
  7. return var
  8. else
  9. return env[k]
  10. end
  11. end,
  12. })
  13. setfenv(func,newenv)
  14. return func
  15. end
  16. cors = {}
  17. mas = Instance.new("Model",game:GetService("Lighting"))
  18. Tool0 = Instance.new("Tool")
  19. Part1 = Instance.new("Part")
  20. SpecialMesh2 = Instance.new("SpecialMesh")
  21. Sound3 = Instance.new("Sound")
  22. Sound4 = Instance.new("Sound")
  23. PointLight5 = Instance.new("PointLight")
  24. Sound6 = Instance.new("Sound")
  25. LocalScript7 = Instance.new("LocalScript")
  26. LocalScript8 = Instance.new("LocalScript")
  27. Script9 = Instance.new("Script")
  28. Tool0.Name = "HyperlaserGun"
  29. Tool0.Parent = mas
  30. Tool0.TextureId = "http://www.roblox.com/asset/?id=130093050"
  31. Tool0.GripPos = Vector3.new(0, -0.100000001, 0.75)
  32. Tool0.CanBeDropped = false
  33. Part1.Name = "Handle"
  34. Part1.Parent = Tool0
  35. Part1.Rotation = Vector3.new(153.539993, -9.7699995, -163.440002)
  36. Part1.FormFactor = Enum.FormFactor.Custom
  37. Part1.Size = Vector3.new(0.580000222, 1.34000099, 2.48000145)
  38. Part1.CFrame = CFrame.new(0.0399999991, 0, 0.0700000003, -0.944598317, 0.280954868, -0.169695258, 0.327697694, 0.836576641, -0.439038545, 0.0186130833, -0.470323801, -0.88229686)
  39. Part1.BottomSurface = Enum.SurfaceType.Smooth
  40. Part1.TopSurface = Enum.SurfaceType.Smooth
  41. Part1.Position = Vector3.new(0.0399999991, 0, 0.0700000003)
  42. Part1.Orientation = Vector3.new(26.039999, -169.110001, 21.3899994)
  43. SpecialMesh2.Parent = Part1
  44. SpecialMesh2.MeshId = "http://www.roblox.com/asset/?id=130099641"
  45. SpecialMesh2.Scale = Vector3.new(0.649999976, 0.649999976, 0.649999976)
  46. SpecialMesh2.TextureId = "http://www.roblox.com/asset/?id=130093033"
  47. SpecialMesh2.MeshType = Enum.MeshType.FileMesh
  48. SpecialMesh2.Scale = Vector3.new(0.649999976, 0.649999976, 0.649999976)
  49. Sound3.Name = "Fire"
  50. Sound3.Parent = Part1
  51. Sound3.SoundId = "http://www.roblox.com/asset?id=130113322"
  52. Sound4.Name = "Reload"
  53. Sound4.Parent = Part1
  54. Sound4.SoundId = "http://www.roblox.com/asset?id=130113370"
  55. PointLight5.Parent = Part1
  56. PointLight5.Color = Color3.new(0, 1, 1)
  57. PointLight5.Range = 6
  58. PointLight5.Color = Color3.new(0, 1, 1)
  59. Sound6.Name = "HitFade"
  60. Sound6.Parent = Part1
  61. Sound6.SoundId = "http://www.roblox.com/asset?id=130113415"
  62. LocalScript7.Name = "ToolScript"
  63. LocalScript7.Parent = Tool0
  64. table.insert(cors,sandbox(LocalScript7,function()
  65. --Rescripted by Luckymaxer
  66.  
  67. Tool = script.Parent
  68. Handle = Tool:WaitForChild("Handle")
  69.  
  70. Players = game:GetService("Players")
  71.  
  72. ServerControl = Tool:WaitForChild("ServerControl")
  73. ClientControl = Tool:WaitForChild("ClientControl")
  74.  
  75. ClientControl.OnClientInvoke = (function(Mode, Value)
  76. if Mode == "PlaySound" and Value then
  77. Value:Play()
  78. end
  79. end)
  80.  
  81. function InvokeServer(Mode, Value, arg)
  82. pcall(function()
  83. ServerControl:InvokeServer(Mode, Value, arg)
  84. end)
  85. end
  86.  
  87. function Equipped(Mouse)
  88. Character = Tool.Parent
  89. Player = Players:GetPlayerFromCharacter(Character)
  90. Humanoid = Character:FindFirstChild("Humanoid")
  91. if not Player or not Humanoid or Humanoid.Health == 0 then
  92. return
  93. end
  94. Mouse.Button1Down:connect(function()
  95. InvokeServer("Click", true, Mouse.Hit.p)
  96. end)
  97. end
  98.  
  99. local function Unequipped()
  100.  
  101. end
  102.  
  103. Tool.Equipped:connect(Equipped)
  104. Tool.Unequipped:connect(Unequipped)
  105. end))
  106. LocalScript8.Name = "MouseIcon"
  107. LocalScript8.Parent = Tool0
  108. table.insert(cors,sandbox(LocalScript8,function()
  109. local MOUSE_ICON = 'rbxasset://textures/GunCursor.png'
  110. local RELOADING_ICON = 'rbxasset://textures/GunWaitCursor.png'
  111.  
  112. local Tool = script.Parent
  113.  
  114. local Mouse = nil
  115.  
  116. local function UpdateIcon()
  117. if Mouse then
  118. Mouse.Icon = Tool.Enabled and MOUSE_ICON or RELOADING_ICON
  119. end
  120. end
  121.  
  122. local function OnEquipped(mouse)
  123. Mouse = mouse
  124. UpdateIcon()
  125. end
  126.  
  127. local function OnChanged(property)
  128. if property == 'Enabled' then
  129. UpdateIcon()
  130. end
  131. end
  132.  
  133. Tool.Equipped:connect(OnEquipped)
  134. Tool.Changed:connect(OnChanged)
  135.  
  136. end))
  137. Script9.Parent = Tool0
  138. table.insert(cors,sandbox(Script9,function()
  139. --Rescripted by Luckymaxer
  140.  
  141. Tool = script.Parent
  142. Handle = Tool:WaitForChild("Handle")
  143.  
  144. Players = game:GetService("Players")
  145. Debris = game:GetService("Debris")
  146.  
  147. Speed = 100
  148. Duration = 1
  149.  
  150. NozzleOffset = Vector3.new(0, 0.4, -1.1)
  151.  
  152. Sounds = {
  153. Fire = Handle:WaitForChild("Fire"),
  154. Reload = Handle:WaitForChild("Reload"),
  155. HitFade = Handle:WaitForChild("HitFade")
  156. }
  157.  
  158. PointLight = Handle:WaitForChild("PointLight")
  159.  
  160. ServerControl = (Tool:FindFirstChild("ServerControl") or Instance.new("RemoteFunction"))
  161. ServerControl.Name = "ServerControl"
  162. ServerControl.Parent = Tool
  163.  
  164. ClientControl = (Tool:FindFirstChild("ClientControl") or Instance.new("RemoteFunction"))
  165. ClientControl.Name = "ClientControl"
  166. ClientControl.Parent = Tool
  167.  
  168. ServerControl.OnServerInvoke = (function(player, Mode, Value, arg)
  169. if player ~= Player or Humanoid.Health == 0 or not Tool.Enabled then
  170. return
  171. end
  172. if Mode == "Click" and Value then
  173. Activated(arg)
  174. end
  175. end)
  176.  
  177. function InvokeClient(Mode, Value)
  178. pcall(function()
  179. ClientControl:InvokeClient(Player, Mode, Value)
  180. end)
  181. end
  182.  
  183. function TagHumanoid(humanoid, player)
  184. local Creator_Tag = Instance.new("ObjectValue")
  185. Creator_Tag.Name = "creator"
  186. Creator_Tag.Value = player
  187. Debris:AddItem(Creator_Tag, 2)
  188. Creator_Tag.Parent = humanoid
  189. end
  190.  
  191. function UntagHumanoid(humanoid)
  192. for i, v in pairs(humanoid:GetChildren()) do
  193. if v:IsA("ObjectValue") and v.Name == "creator" then
  194. v:Destroy()
  195. end
  196. end
  197. end
  198.  
  199. function FindCharacterAncestor(Parent)
  200. if Parent and Parent ~= game:GetService("Workspace") then
  201. local humanoid = Parent:FindFirstChild("Humanoid")
  202. if humanoid then
  203. return Parent, humanoid
  204. else
  205. return FindCharacterAncestor(Parent.Parent)
  206. end
  207. end
  208. return nil
  209. end
  210.  
  211. function GetTransparentsRecursive(Parent, PartsTable)
  212. local PartsTable = (PartsTable or {})
  213. for i, v in pairs(Parent:GetChildren()) do
  214. local TransparencyExists = false
  215. pcall(function()
  216. local Transparency = v["Transparency"]
  217. if Transparency then
  218. TransparencyExists = true
  219. end
  220. end)
  221. if TransparencyExists then
  222. table.insert(PartsTable, v)
  223. end
  224. GetTransparentsRecursive(v, PartsTable)
  225. end
  226. return PartsTable
  227. end
  228.  
  229. function SelectionBoxify(Object)
  230. local SelectionBox = Instance.new("SelectionBox")
  231. SelectionBox.Adornee = Object
  232. SelectionBox.Color = BrickColor.new("Toothpaste")
  233. SelectionBox.Parent = Object
  234. return SelectionBox
  235. end
  236.  
  237. local function Light(Object)
  238. local Light = PointLight:Clone()
  239. Light.Range = (Light.Range + 2)
  240. Light.Parent = Object
  241. end
  242.  
  243. function FadeOutObjects(Objects, FadeIncrement)
  244. repeat
  245. local LastObject = nil
  246. for i, v in pairs(Objects) do
  247. v.Transparency = (v.Transparency + FadeIncrement)
  248. LastObject = v
  249. end
  250. wait()
  251. until LastObject.Transparency >= 1 or not LastObject
  252. end
  253.  
  254. function Dematerialize(character, humanoid, FirstPart)
  255. if not character or not humanoid then
  256. return
  257. end
  258.  
  259. humanoid.WalkSpeed = 0
  260.  
  261. local Parts = {}
  262.  
  263. for i, v in pairs(character:GetChildren()) do
  264. if v:IsA("BasePart") then
  265. v.Anchored = true
  266. table.insert(Parts, v)
  267. elseif v:IsA("LocalScript") or v:IsA("Script") then
  268. v:Destroy()
  269. end
  270. end
  271.  
  272. local SelectionBoxes = {}
  273.  
  274. local FirstSelectionBox = SelectionBoxify(FirstPart)
  275. Light(FirstPart)
  276. wait(0.05)
  277.  
  278. for i, v in pairs(Parts) do
  279. if v ~= FirstPart then
  280. table.insert(SelectionBoxes, SelectionBoxify(v))
  281. Light(v)
  282. end
  283. end
  284.  
  285. local ObjectsWithTransparency = GetTransparentsRecursive(character)
  286. FadeOutObjects(ObjectsWithTransparency, 0.1)
  287.  
  288. wait(0.5)
  289.  
  290. character:BreakJoints()
  291. humanoid.Health = 0
  292.  
  293. Debris:AddItem(character, 2)
  294.  
  295. local FadeIncrement = 0.05
  296. Delay(0.2, function()
  297. FadeOutObjects({FirstSelectionBox}, FadeIncrement)
  298. if character and character.Parent then
  299. character:Destroy()
  300. end
  301. end)
  302. FadeOutObjects(SelectionBoxes, FadeIncrement)
  303. end
  304.  
  305. function Touched(Projectile, Hit)
  306. if not Hit or not Hit.Parent then
  307. return
  308. end
  309. local character, humanoid = FindCharacterAncestor(Hit)
  310. if character and humanoid and character ~= Character then
  311. local ForceFieldExists = false
  312. for i, v in pairs(character:GetChildren()) do
  313. if v:IsA("ForceField") then
  314. ForceFieldExists = true
  315. end
  316. end
  317. if not ForceFieldExists then
  318. if Projectile then
  319. local HitFadeSound = Projectile:FindFirstChild(Sounds.HitFade.Name)
  320. local torso = humanoid.Torso
  321. if HitFadeSound and torso then
  322. HitFadeSound.Parent = torso
  323. HitFadeSound:Play()
  324. end
  325. end
  326. Dematerialize(character, humanoid, Hit)
  327. end
  328. if Projectile and Projectile.Parent then
  329. Projectile:Destroy()
  330. end
  331. end
  332. end
  333.  
  334. function Equipped()
  335. Character = Tool.Parent
  336. Player = Players:GetPlayerFromCharacter(Character)
  337. Humanoid = Character:FindFirstChild("Humanoid")
  338. if not Player or not Humanoid or Humanoid.Health == 0 then
  339. return
  340. end
  341. end
  342.  
  343. function Activated(target)
  344. if Tool.Enabled and Humanoid.Health > 0 then
  345. Tool.Enabled = false
  346.  
  347. InvokeClient("PlaySound", Sounds.Fire)
  348.  
  349. local HandleCFrame = Handle.CFrame
  350. local FiringPoint = HandleCFrame.p + HandleCFrame:vectorToWorldSpace(NozzleOffset)
  351. local ShotCFrame = CFrame.new(FiringPoint, target)
  352.  
  353. local LaserShotClone = BaseShot:Clone()
  354. LaserShotClone.CFrame = ShotCFrame + (ShotCFrame.lookVector * (BaseShot.Size.Z / 2))
  355. local BodyVelocity = Instance.new("BodyVelocity")
  356. BodyVelocity.velocity = ShotCFrame.lookVector * Speed
  357. BodyVelocity.Parent = LaserShotClone
  358. LaserShotClone.Touched:connect(function(Hit)
  359. if not Hit or not Hit.Parent then
  360. return
  361. end
  362. Touched(LaserShotClone, Hit)
  363. end)
  364. Debris:AddItem(LaserShotClone, Duration)
  365. LaserShotClone.Parent = game:GetService("Workspace")
  366.  
  367. wait(0.6) -- FireSound length
  368.  
  369. InvokeClient("PlaySound", Sounds.Reload)
  370.  
  371. wait(0.75) -- ReloadSound length
  372.  
  373. Tool.Enabled = true
  374. end
  375. end
  376.  
  377. function Unequipped()
  378.  
  379. end
  380.  
  381. BaseShot = Instance.new("Part")
  382. BaseShot.Name = "Effect"
  383. BaseShot.BrickColor = BrickColor.new("Toothpaste")
  384. BaseShot.Material = Enum.Material.Plastic
  385. BaseShot.Shape = Enum.PartType.Block
  386. BaseShot.TopSurface = Enum.SurfaceType.Smooth
  387. BaseShot.BottomSurface = Enum.SurfaceType.Smooth
  388. BaseShot.FormFactor = Enum.FormFactor.Custom
  389. BaseShot.Size = Vector3.new(0.2, 0.2, 3)
  390. BaseShot.CanCollide = false
  391. BaseShot.Locked = true
  392. SelectionBoxify(BaseShot)
  393. Light(BaseShot)
  394. BaseShotSound = Sounds.HitFade:Clone()
  395. BaseShotSound.Parent = BaseShot
  396.  
  397. Tool.Equipped:connect(Equipped)
  398. Tool.Unequipped:connect(Unequipped)
  399. end))
  400. for i,v in pairs(mas:GetChildren()) do
  401. v.Parent = game:GetService("Players").LocalPlayer.Backpack
  402. pcall(function() v:MakeJoints() end)
  403. end
  404. mas:Destroy()
  405. for i,v in pairs(cors) do
  406. spawn(function()
  407. pcall(v)
  408. end)
  409. end
Add Comment
Please, Sign In to add comment