Advertisement
spacemonkey3591

fiwejhiwg

Jun 16th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.02 KB | None | 0 0
  1. --Created with PenguinAnonymous's compiler
  2. --PenguinAnonymous is not responsible for damages caused to your game
  3. --This plugin does not remove things
  4. --PenguinAnonymous cannot be held resonsible for manual deletion for the purpose of testing
  5. --Keep in mind, any items that cause errors in compilation will be skipped and documented within the last line of the disclaimer comments
  6. --Thank you for using my plugin and enjoy :)
  7. --It is free to use
  8. --If you use this plugin to create your own, please give me credit
  9. --Z_V edited my plugin to look like his own and published it without giving me credit, and that makes me very angry
  10. --Errors:
  11. local runDummyScript = function(f,scri)
  12. local oldenv = getfenv(f)
  13. local newenv = setmetatable({}, {
  14. __index = function(_, k)
  15. if k:lower() == 'script' then
  16. return scri
  17. else
  18. return oldenv[k]
  19. end
  20. end
  21. })
  22. setfenv(f, newenv)
  23. ypcall(function() f() end)
  24. end
  25. cors = {}
  26. mas = Instance.new("Model",game:GetService("Lighting"))
  27. mas.Name = "CompiledModel"
  28. o1 = Instance.new("Tool")
  29. o2 = Instance.new("Part")
  30. o3 = Instance.new("SpecialMesh")
  31. o4 = Instance.new("Sound")
  32. o5 = Instance.new("LocalScript")
  33. o6 = Instance.new("Script")
  34. o7 = Instance.new("Sound")
  35. o8 = Instance.new("Animation")
  36. o9 = Instance.new("LocalScript")
  37. o1.Name = "Taser"
  38. o1.Parent = game.Players.LocalPlayer.Backpack
  39. o1.TextureId = "http://www.roblox.com/asset/?id=99866630"
  40. o1.GripPos = Vector3.new(0, 0, 0.400000006)
  41. o1.ToolTip = "Shocker"
  42. o1.CanBeDropped = false
  43. o2.Name = "Handle"
  44. o2.Parent = o1
  45. o2.Rotation = Vector3.new(0, -89.9700012, 0)
  46. o2.FormFactor = Enum.FormFactor.Custom
  47. o2.Size = Vector3.new(0.259999961, 0.590000153, 1.40000045)
  48. o2.CFrame = CFrame.new(0, 0, 0, 0, 0, -0.999999881, -6.30617142e-05, 1.00000024, 0, 1.00000024, 6.30617142e-05, 0)
  49. o2.BottomSurface = Enum.SurfaceType.Smooth
  50. o2.TopSurface = Enum.SurfaceType.Smooth
  51. o3.Parent = o2
  52. o3.MeshId = "http://www.roblox.com/asset/?id=99866654"
  53. o3.Scale = Vector3.new(0.5, 0.5, 0.5)
  54. o3.TextureId = "http://www.roblox.com/asset/?id=99866675"
  55. o3.MeshType = Enum.MeshType.FileMesh
  56. o4.Name = "StunGunLoop"
  57. o4.Parent = o2
  58. o4.SoundId = "http://www.roblox.com/asset/?id=101178423"
  59. o4.Looped = true
  60. o5.Name = "Taser"
  61. o5.Parent = o1
  62. table.insert(cors,coroutine.create(function()
  63. wait()
  64. runDummyScript(function()
  65. -----------------
  66. --| Constants |--
  67. -----------------
  68.  
  69. local COOLDOWN = 5 -- Seconds until tool can be used again
  70.  
  71. local WIRE_LENGTH = 30
  72. local WIRE_SPEED = 20
  73. local WIRE_THICKNESS = 0.1
  74. local HIT_ZONE_HALF_SIZE = Vector3.new(0.5, 0.5, 0.5) / 2
  75.  
  76. local ONE_STEP = 1 / 30
  77.  
  78. local AIMING_CFRAME = CFrame.new(0.25, 0, 0.4, 0.8, 0, 0.6, 0, 1, 0, -0.6, 0, 0.8)
  79.  
  80. --------------------
  81. --| WaitForChild |--
  82. --------------------
  83.  
  84. -- Waits for parent.child to exist, then returns it
  85. local function WaitForChild(parent, childName)
  86. assert(parent, "ERROR: WaitForChild: parent is nil")
  87. while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
  88. return parent[childName]
  89. end
  90.  
  91. -----------------
  92. --| Variables |--
  93. -----------------
  94.  
  95. local DebrisService = Game:GetService('Debris')
  96. local PlayersService = Game:GetService('Players')
  97.  
  98. local Tool = script.Parent
  99. local ToolHandle = Tool.Handle
  100.  
  101. local StunScript = WaitForChild(script, 'Stun')
  102. local ReadyAimAnimation = WaitForChild(script, 'ReadyAim2')
  103.  
  104. local StunGunLoopSound = WaitForChild(ToolHandle, 'StunGunLoop')
  105.  
  106. local OriginalToolGrip = Tool.Grip
  107.  
  108. local MyModel = nil
  109. local MyHumanoid = nil
  110. local CreatorTag = nil
  111.  
  112. local ReadyAimTrack = nil
  113.  
  114. local WireBases = {}
  115.  
  116. local Done = false
  117.  
  118. local BodyPosition = nil
  119.  
  120. -------------------------
  121. --| Utility Functions |--
  122. -------------------------
  123.  
  124. -- Returns the ancestor that contains a Humanoid, if it exists
  125. local function FindCharacterAncestor(subject)
  126. if subject and subject ~= Workspace then
  127. local humanoid = subject:FindFirstChild('Humanoid')
  128. if humanoid then
  129. return subject, humanoid
  130. else
  131. return FindCharacterAncestor(subject.Parent)
  132. end
  133. end
  134. return nil
  135. end
  136.  
  137. local function WeldInPlace(part0, part1, name, parent)
  138. local weld = Instance.new('Weld')
  139. weld.Part0 = part0
  140. weld.Part1 = part1
  141. weld.C0 = CFrame.new()
  142. weld.C1 = part1.CFrame:inverse() * part0.CFrame
  143. weld.Name = name or 'Weld'
  144. weld.Parent = parent or part0
  145. return weld
  146. end
  147.  
  148. ------------------------
  149. --| Helper Functions |--
  150. ------------------------
  151.  
  152. local function MakeWireBase(parentPart, weldOffset)
  153. local wireBase = Instance.new('Part')
  154. wireBase.Name = "WireBase"
  155. wireBase.CanCollide = false
  156. wireBase.FormFactor = Enum.FormFactor.Custom --NOTE: This must be done before changing Size
  157. wireBase.Size = Vector3.new(0.2, 0.2, 0.2) -- Intentional
  158. wireBase.BottomSurface = Enum.SurfaceType.Smooth
  159. wireBase.TopSurface = Enum.SurfaceType.Smooth
  160.  
  161. local weld = Instance.new('Weld', wireBase)
  162. weld.Part0 = parentPart
  163. weld.Part1 = wireBase
  164. weld.C0 = CFrame.new(weldOffset)
  165.  
  166. local wire = Instance.new('BlockMesh', wireBase)
  167. wire.Name = 'Wire'
  168. wire.Scale = Vector3.new(WIRE_THICKNESS, WIRE_THICKNESS, 0)
  169.  
  170. wireBase.Parent = parentPart
  171. return wireBase
  172. end
  173.  
  174. local function UnStick()
  175. --print("UnStick")
  176. if MyModel and MyHumanoid then
  177. local torso = MyModel:FindFirstChild('Torso')
  178. if torso then
  179. MyHumanoid.WalkSpeed = 16
  180. if BodyPosition then
  181. BodyPosition:Destroy()
  182. BodyPosition = nil
  183. end
  184. end
  185. end
  186. end
  187.  
  188. local function ShotComplete(playExtras)
  189. --print("ShotComplete, playExtras:", playExtras)
  190.  
  191. if ReadyAimTrack then ReadyAimTrack:Stop() end
  192. wait(0.1)
  193. Tool.Grip = OriginalToolGrip
  194. wait(0.1)
  195. UnStick()
  196.  
  197. if playExtras then
  198. --TODO: play reload animation
  199. --TODO: play reload sound
  200. end
  201.  
  202. wait(COOLDOWN)
  203.  
  204. Tool.Enabled = true
  205. end
  206.  
  207. local function Stopped(hitPart)
  208. --print("Stopped:", hitPart)
  209. if Done then return end
  210. Done = true
  211.  
  212. StunGunLoopSound:Stop()
  213.  
  214. if hitPart then
  215. --TODO: play hit sound
  216. --TODO: wires flash
  217. local character, humanoid = FindCharacterAncestor(hitPart.Parent)
  218. if character ~= MyModel and humanoid and humanoid.Health > 0 then
  219. local stunScriptClone = StunScript:Clone()
  220. stunScriptClone.Parent = humanoid
  221. stunScriptClone.Disabled = false
  222. end
  223. else
  224. --TODO: play out of wire sound
  225. --TODO: wires disappear
  226. end
  227.  
  228. for _, wireBase in pairs(WireBases) do
  229. local wire = wireBase:FindFirstChild('Wire')
  230. if wire then
  231. wire.Scale = Vector3.new(WIRE_THICKNESS, WIRE_THICKNESS, 0)
  232. wire.Offset = Vector3.new()
  233. end
  234. end
  235.  
  236. ShotComplete(true)
  237. end
  238.  
  239. local function FireWire(wireBase, targetPoint)
  240. --print("FireWire:", wireBase, targetPoint)
  241. if not wireBase or not targetPoint then return end
  242. local weld = wireBase:FindFirstChild('Weld')
  243. if weld then
  244. --weld.C1 = CFrame.new(Vector3.new(), targetPoint - wireBase.Position)
  245. wireBase.Anchored = true
  246. weld:Destroy()
  247. wireBase.CFrame = CFrame.new(wireBase.Position, targetPoint)
  248.  
  249. wait(0) -- Wtf
  250. WeldInPlace(ToolHandle, wireBase, _, wireBase)
  251. wireBase.Anchored = false
  252. end
  253. local wire = wireBase:FindFirstChild('Wire')
  254. Done = false
  255. Spawn(function()
  256. while wireBase and wire and (wire.Scale.Z * wireBase.Size.Z) < WIRE_LENGTH and not Done do
  257. -- Check the end of the wire for a hit
  258. local wireEndPoint = wireBase.CFrame * Vector3.new(0, 0, wire.Offset.Z * 2)
  259. local ray = Ray.new(wireBase.Position, (wireEndPoint - wireBase.Position))
  260. local part = Workspace:FindPartOnRay(ray, MyModel)
  261. if part then
  262. return Stopped(part)
  263. else -- No hit, not out of wire, just keep going
  264. local increment = Vector3.new(0, 0, WIRE_SPEED) -- How many 0.2 lengths each time
  265. wire.Offset = wire.Offset - (increment * (wireBase.Size.Z / 2))
  266. wire.Scale = wire.Scale + increment
  267. end
  268. wait(ONE_STEP)
  269. end
  270. Stopped() -- Out of wire
  271. end)
  272. end
  273.  
  274. ----------------------
  275. --| Tool Functions |--
  276. ----------------------
  277.  
  278. local function OnEquipped()
  279. MyModel = Tool.Parent
  280. MyHumanoid = MyModel:FindFirstChild('Humanoid')
  281. CreatorTag.Value = PlayersService:GetPlayerFromCharacter(MyModel)
  282.  
  283. -- Make top and bottom wire bases
  284. local front = -ToolHandle.Size.Z / 2
  285. table.insert(WireBases, MakeWireBase(ToolHandle, Vector3.new(0, -0.17, front)))
  286. table.insert(WireBases, MakeWireBase(ToolHandle, Vector3.new(0, 0.17, front)))
  287.  
  288. if MyHumanoid then
  289. -- Preload animations
  290. ReadyAimTrack = MyHumanoid:LoadAnimation(ReadyAimAnimation)
  291. end
  292. end
  293.  
  294. local function OnActivated(targetOverride)
  295. if Tool.Enabled and MyModel and MyHumanoid and MyHumanoid.Health > 0 then
  296. local torso = MyModel:FindFirstChild('Torso')
  297. if torso then
  298. Tool.Enabled = false
  299.  
  300. -- Pick a target
  301. local targetPosition = targetOverride or MyHumanoid.TargetPoint
  302.  
  303. -- Freeze our character
  304. MyHumanoid.WalkSpeed = 0
  305. BodyPosition = Instance.new('BodyPosition')
  306. BodyPosition.maxForce = Vector3.new(1e6, 1e6, 1e6)
  307. BodyPosition.position = torso.Position
  308. DebrisService:AddItem(BodyPosition, 10)
  309. BodyPosition.Parent = torso
  310.  
  311. -- Face the target horizontally
  312. torso.CFrame = CFrame.new(torso.Position, Vector3.new(targetPosition.X, torso.Position.Y, targetPosition.Z))
  313.  
  314. -- Ready, aim...
  315. if ReadyAimTrack then
  316. ReadyAimTrack:Play()
  317. end
  318. wait(0.1)
  319. Tool.Grip = AIMING_CFRAME
  320. wait(0.1)
  321.  
  322. -- Fire!
  323. StunGunLoopSound:Play()
  324. for _, wireBase in pairs(WireBases) do
  325. FireWire(wireBase, targetPosition)
  326. end
  327. end
  328. end
  329. end
  330.  
  331. local function OnUnequipped()
  332. for _, wireBase in pairs(WireBases) do
  333. wireBase:Destroy()
  334. end
  335. WireBases = {}
  336.  
  337. -- Stop animations
  338. if ReadyAimTrack then ReadyAimTrack:Stop() end
  339.  
  340. ShotComplete(false)
  341. end
  342.  
  343. -- Also activate when the Action Button is pressed
  344. local function OnChildAdded(child)
  345. if child.Name == 'ActionButtonData' then
  346. child.Changed:connect(function(newValue)
  347. local bindable = child:FindFirstChild('GetTargetPosition')
  348. if bindable and string.sub(newValue, 1, 1) == 'v' then
  349. local matches = {}
  350. for match in string.gmatch(newValue, '%d+%.?%d*') do
  351. table.insert(matches, match)
  352. end
  353. if #matches == 4 then
  354. local screenPosition = Vector2.new(matches[1], matches[2])
  355. local screenSize = Vector2.new(matches[3], matches[4])
  356. local targetPosition = bindable:Invoke(screenPosition, screenSize, {MyModel})
  357. OnActivated(targetPosition)
  358. end
  359. end
  360. end)
  361. end
  362. end
  363.  
  364. --------------------
  365. --| Script Logic |--
  366. --------------------
  367.  
  368. CreatorTag = Instance.new('ObjectValue')
  369. CreatorTag.Name = 'creator' --NOTE: Must be called 'creator' for website stats
  370. local nameTag = Instance.new('StringValue', CreatorTag)
  371. nameTag.Name = 'weaponName'
  372. nameTag.Value = Tool.Name
  373. local iconTag = Instance.new('StringValue', CreatorTag)
  374. iconTag.Name = 'weaponIcon'
  375. iconTag.Value = Tool.TextureId
  376. CreatorTag.Parent = StunScript
  377.  
  378. Tool.Equipped:connect(OnEquipped)
  379. Tool.Activated:connect(OnActivated)
  380. Tool.Unequipped:connect(OnUnequipped)
  381.  
  382. -- Listen for Action Button Data Object
  383. for _, child in pairs(Tool:GetChildren()) do
  384. OnChildAdded(child)
  385. end
  386. Tool.ChildAdded:connect(OnChildAdded)
  387.  
  388. end,o5)
  389. end))
  390. o6.Name = "Stun"
  391. o6.Parent = o5
  392. o6.Disabled = true
  393. table.insert(cors,coroutine.create(function()
  394. wait()
  395. runDummyScript(function()
  396. -----------------
  397. --| Constants |--
  398. -----------------
  399.  
  400. local STUN_TIME = 3 -- Seconds
  401.  
  402. local DAMAGE = 3
  403. local DAMAGE_FREQUENCY = 0.4 -- Seconds
  404.  
  405. local ONE_STEP = 1 / 30
  406.  
  407. --------------------
  408. --| WaitForChild |--
  409. --------------------
  410.  
  411. -- Waits for parent.child to exist, then returns it
  412. local function WaitForChild(parent, childName)
  413. assert(parent, "ERROR: WaitForChild: parent is nil")
  414. while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
  415. return parent[childName]
  416. end
  417.  
  418. -----------------
  419. --| Variables |--
  420. -----------------
  421.  
  422. local DebrisService = Game:GetService('Debris')
  423.  
  424. local Humanoid = script.Parent
  425. local OriginalWalkSpeed = Humanoid.WalkSpeed
  426. local HitBindable = Humanoid:FindFirstChild('Hit')
  427.  
  428. local ZapSound = WaitForChild(script, 'Zap')
  429.  
  430. local CreatorTag = WaitForChild(script, 'creator')
  431.  
  432. local StartTime = tick()
  433. local LastDamageTime = StartTime
  434.  
  435. -----------------
  436. --| Functions |--
  437. -----------------
  438.  
  439. local function ApplyTag(target)
  440. while target:FindFirstChild('creator') do
  441. target.creator:Destroy()
  442. end
  443.  
  444. local creatorTagClone = CreatorTag:Clone()
  445. DebrisService:AddItem(creatorTagClone, 4)
  446. creatorTagClone.Parent = target
  447. end
  448.  
  449. --------------------
  450. --| Script Logic |--
  451. --------------------
  452.  
  453. ZapSound.Parent = Humanoid.Torso
  454.  
  455. repeat
  456. local now = tick()
  457.  
  458. Humanoid.WalkSpeed = 0
  459.  
  460. if now - LastDamageTime > DAMAGE_FREQUENCY then
  461. if ZapSound.Parent ~= script then
  462. ZapSound:Play()
  463. end
  464. if HitBindable then -- (Battle-specific)
  465. HitBindable:Invoke(DAMAGE, CreatorTag)
  466. else
  467. print("Could not find BindableFunction 'Hit'")
  468. ApplyTag(Humanoid)
  469. Humanoid:TakeDamage(DAMAGE)
  470. end
  471. LastDamageTime = now
  472. end
  473.  
  474. wait(ONE_STEP)
  475. until now - StartTime >= STUN_TIME
  476.  
  477. Humanoid.WalkSpeed = OriginalWalkSpeed
  478.  
  479. ZapSound:Destroy()
  480. script:Destroy()
  481.  
  482. end,o6)
  483. end))
  484. o7.Name = "Zap"
  485. o7.Parent = o6
  486. o7.SoundId = "http://www.roblox.com/asset/?id=101180005"
  487. o8.Name = "ReadyAim2"
  488. o8.Parent = o5
  489. o8.AnimationId = "http://www.roblox.com/Asset?ID=101097290"
  490. o9.Name = "MouseIcon"
  491. o9.Parent = o1
  492. table.insert(cors,coroutine.create(function()
  493. wait()
  494. runDummyScript(function()
  495. local MOUSE_ICON = 'rbxasset://textures/GunCursor.png'
  496. local RELOADING_ICON = 'rbxasset://textures/GunWaitCursor.png'
  497.  
  498. local Tool = script.Parent
  499.  
  500. local Mouse = nil
  501.  
  502. local function UpdateIcon()
  503. if Mouse then
  504. Mouse.Icon = Tool.Enabled and MOUSE_ICON or RELOADING_ICON
  505. end
  506. end
  507.  
  508. local function OnEquipped(mouse)
  509. Mouse = mouse
  510. UpdateIcon()
  511. end
  512.  
  513. local function OnChanged(property)
  514. if property == 'Enabled' then
  515. UpdateIcon()
  516. end
  517. end
  518.  
  519. Tool.Equipped:connect(OnEquipped)
  520. Tool.Changed:connect(OnChanged)
  521.  
  522. end,o9)
  523. end))
  524. mas.Parent = workspace
  525. mas:MakeJoints()
  526. local mas1 = mas:GetChildren()
  527. for i=1,#mas1 do
  528. mas1[i].Parent = script
  529. ypcall(function() mas1[i]:MakeJoints() end)
  530. end
  531. mas:Destroy()
  532. for i=1,#cors do
  533. coroutine.resume(cors[i])
  534. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement