Advertisement
BNutty07

Chainsaw Thrower

Nov 12th, 2017
834
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.96 KB | None | 0 0
  1.  
  2. --Converted with ttyyuu12345's model to script plugin v4
  3. function sandbox(var,func)
  4. local env = getfenv(func)
  5. local newenv = setmetatable({},{
  6. __index = function(self,k)
  7. if k=="script" then
  8. return var
  9. else
  10. return env[k]
  11. end
  12. end,
  13. })
  14. setfenv(func,newenv)
  15. return func
  16. end
  17. cors = {}
  18. mas = Instance.new("Model",game:GetService("Lighting"))
  19. Script0 = Instance.new("Script")
  20. Script1 = Instance.new("Script")
  21. Script2 = Instance.new("Script")
  22. Sound3 = Instance.new("Sound")
  23. Sound4 = Instance.new("Sound")
  24. Sound5 = Instance.new("Sound")
  25. Sound6 = Instance.new("Sound")
  26. Sound7 = Instance.new("Sound")
  27. Sound8 = Instance.new("Sound")
  28. Sound9 = Instance.new("Sound")
  29. Sound10 = Instance.new("Sound")
  30. Sound11 = Instance.new("Sound")
  31. Tool12 = Instance.new("Tool")
  32. Script13 = Instance.new("Script")
  33. LocalScript14 = Instance.new("LocalScript")
  34. RemoteEvent15 = Instance.new("RemoteEvent")
  35. Animation16 = Instance.new("Animation")
  36. Part17 = Instance.new("Part")
  37. SpecialMesh18 = Instance.new("SpecialMesh")
  38. Sound19 = Instance.new("Sound")
  39. Sound20 = Instance.new("Sound")
  40. Script21 = Instance.new("Script")
  41. Script0.Name = "BloodLoader"
  42. Script0.Parent = mas
  43. table.insert(cors,sandbox(Script0,function()
  44. print("Draco_Studios' Blood Script has been loaded!")
  45. if script.Parent:FindFirstChild("DeleteMe") then
  46. script.Parent.DeleteMe:Destroy()
  47. end
  48. script.Parent=game.ServerScriptService
  49. game.Players.PlayerAdded:connect(function(p)
  50. p.CharacterAdded:connect(function(c)
  51. script.BloodPool:Clone().Parent=c
  52. c.Humanoid.Died:connect(function()
  53. wait(6)
  54. script.BloodPool:Clone().Parent=c
  55. end)
  56. end)
  57. end)
  58. end))
  59. Script1.Name = "BloodPool"
  60. Script1.Parent = Script0
  61. table.insert(cors,sandbox(Script1,function()
  62. local Char=script.Parent
  63. local Hum=Char:WaitForChild("Humanoid")
  64. local Tor=Char:WaitForChild("Torso")
  65. local M=math.random
  66. local R=math.rad
  67. local rates={0.05,0.075,0.1,0.15}
  68.  
  69. local smooth=function(P)
  70. local SM=Enum.SurfaceType.SmoothNoOutlines
  71. P.TopSurface=SM
  72. P.BottomSurface=SM
  73. P.RightSurface=SM
  74. P.LeftSurface=SM
  75. P.FrontSurface=SM
  76. P.BackSurface=SM
  77. end
  78.  
  79. local function BloodPool(Part,Size)
  80. local Pool=Instance.new("Part",game.Workspace)
  81. Pool.TopSurface=0
  82. Pool.CanCollide=false
  83. Pool.BrickColor=BrickColor.new("Crimson")
  84. Instance.new("CylinderMesh",Pool)
  85. Pool.Anchored=true
  86. Pool.Name="BloodPoolPart"
  87. smooth(Pool)
  88. Pool.FormFactor=Enum.FormFactor.Custom
  89. Pool.Size=Size
  90. local c=Part.CFrame*CFrame.new(M(-3.01,3.01),-2.9,M(-3.01,3.01))
  91. coroutine.resume(coroutine.create(function()
  92. local rate=rates[M(1,#rates)]
  93. game.Debris:AddItem(Pool,15)
  94. for i=1,M(25,70) do
  95. wait()
  96. Pool.CFrame=c
  97. Pool.Size=Pool.Size+Vector3.new(rate,0,rate)
  98. end
  99. wait(5)
  100. Pool:Destroy()
  101. end))
  102. end
  103.  
  104. local function BloodDrops(Size,Area)
  105. local Blood=Instance.new("Part",game.Workspace)
  106. Blood.BrickColor=BrickColor.new("Crimson")
  107. Blood.TopSurface=0
  108. Blood.CanCollide=false
  109. Blood.Anchored=false
  110. Blood.FormFactor=Enum.FormFactor.Custom
  111. Blood.Size=Size
  112. Blood.CFrame=Area*CFrame.new(M(-1.00,1.00),M(-1.00,1.00),M(-1.00,1.00))
  113. return Blood
  114. end
  115.  
  116.  
  117. local Heath=Hum.Health
  118.  
  119. Hum.Changed:connect(function()
  120. if Hum.Health<Heath then
  121. Heath=Hum.Health
  122. for i=1, math.random(4,10)do
  123. local Size=Vector3.new(M(-0.25,0.25),.2,M(-.25,.25))
  124. local Blood=BloodDrops(Size,Tor.CFrame)
  125. local Stopper=false
  126. local Size2=Vector3.new(M(-0.25,0.25),.2,M(-.25,.25))
  127. BloodPool(Tor,Size2)
  128. end
  129. end
  130. end)
  131. end))
  132. Script2.Name = "DiedScript"
  133. Script2.Parent = mas
  134. table.insert(cors,sandbox(Script2,function()
  135. function Died(p)
  136. wait(.001)
  137. local tracks=script:GetChildren()
  138. local rn=math.random(1,#tracks)
  139. local track=tracks[rn]
  140. if track~=nil then
  141. track:play()
  142. wait(5)
  143. track:pause()
  144. end
  145. end
  146.  
  147. function Hum(p)
  148. hum = p:findFirstChild("Humanoid")
  149. if hum ~= nil then
  150. hum.Died:connect(function(hum) Died(p) end)
  151. end
  152. end
  153.  
  154. function Enter(p)
  155. p.CharacterAdded:connect(Hum)
  156. end
  157. game.Players.PlayerAdded:connect(Enter)
  158.  
  159. end))
  160. Sound3.Parent = Script2
  161. Sound3.SoundId = "rbxassetid://232921590"
  162. Sound4.Parent = Script2
  163. Sound4.SoundId = "rbxassetid://232921580"
  164. Sound5.Parent = Script2
  165. Sound5.SoundId = "rbxassetid://232921573"
  166. Sound6.Parent = Script2
  167. Sound6.SoundId = "rbxassetid://169907033"
  168. Sound7.Parent = Script2
  169. Sound7.SoundId = "rbxassetid://167094166"
  170. Sound8.Parent = Script2
  171. Sound8.SoundId = "rbxassetid://166221396"
  172. Sound9.Parent = Script2
  173. Sound9.SoundId = "rbxassetid://166221367"
  174. Sound10.Parent = Script2
  175. Sound10.SoundId = "rbxassetid://166221318"
  176. Sound11.Parent = Script2
  177. Sound11.SoundId = "rbxassetid://166221285"
  178. Tool12.Parent = mas
  179. Tool12.TextureId = "http://www.roblox.com/asset/?id=210600756"
  180. Tool12.GripForward = Vector3.new(-0, -0.707106769, -0.707106769)
  181. Tool12.GripPos = Vector3.new(0, -0.300000012, 0.699999988)
  182. Tool12.GripUp = Vector3.new(0, 0.707106769, -0.707106769)
  183. Script13.Name = "Server"
  184. Script13.Parent = Tool12
  185. table.insert(cors,sandbox(Script13,function()
  186. local Tool = script.Parent
  187. local Remote = Tool:WaitForChild("Remote")
  188. local Handle = Tool:WaitForChild("Handle")
  189.  
  190. local FriendlyFire = false
  191.  
  192. local AttackPower = 1
  193. local AttackDamage = 100
  194. local AtackRechargeTime = 3
  195. local AttackRecharge = 1/AtackRechargeTime
  196. local AttackSpeed = 256
  197.  
  198. local Equipped = false
  199. local Heartbeat = game:GetService("RunService").Heartbeat
  200.  
  201. local Knives = {}
  202.  
  203. --returns the wielding player of this tool
  204. function getPlayer()
  205. local char = Tool.Parent
  206. return game:GetService("Players"):GetPlayerFromCharacter(char)
  207. end
  208.  
  209. --helpfully checks a table for a specific value
  210. function contains(t, v)
  211. for _, val in pairs(t) do
  212. if val == v then
  213. return true
  214. end
  215. end
  216. return false
  217. end
  218.  
  219. --tags a human for the ROBLOX KO system
  220. function tagHuman(human)
  221. local tag = Instance.new("ObjectValue")
  222. tag.Value = getPlayer()
  223. tag.Name = "creator"
  224. tag.Parent = human
  225. game:GetService("Debris"):AddItem(tag)
  226. end
  227.  
  228. --used by checkTeams
  229. function sameTeam(otherHuman)
  230. local player = getPlayer()
  231. local otherPlayer = game:GetService("Players"):GetPlayerFromCharacter(otherHuman.Parent)
  232. if player and otherPlayer then
  233. return player.TeamColor == otherPlayer.TeamColor
  234. end
  235. return false
  236. end
  237.  
  238. --use this to determine if you want this human to be harmed or not, returns boolean
  239. function checkTeams(otherHuman)
  240. return not (sameTeam(otherHuman) and not FriendlyFire)
  241. end
  242.  
  243. function getKnife()
  244. local knife = Handle:clone()
  245. knife.Transparency = 0
  246. knife.Hit.Pitch = math.random(90, 110)/100
  247.  
  248. local lift = Instance.new("BodyForce")
  249. lift.force = Vector3.new(0, 196.2, 0) * knife:GetMass() * 0.8
  250. lift.Parent = knife
  251.  
  252. local proj = Tool.Projectile:Clone()
  253. proj.Disabled = false
  254. proj.Parent = knife
  255.  
  256. return knife
  257. end
  258.  
  259. function equippedLoop()
  260. while Equipped do
  261. local dt = Heartbeat:wait()
  262.  
  263. if AttackPower < 1 then
  264. AttackPower = AttackPower + dt * AttackRecharge
  265. if AttackPower > 1 then
  266. AttackPower = 1
  267. end
  268. end
  269.  
  270. Handle.Transparency = 1 - AttackPower
  271. end
  272. end
  273.  
  274. function onLeftDown(mousePos)
  275. local knife = getKnife()
  276. knife.CFrame = CFrame.new(Handle.Position, mousePos)
  277. knife.Velocity = knife.CFrame.lookVector * AttackSpeed * AttackPower
  278. local damage = AttackDamage * AttackPower
  279. local touched
  280. touched = knife.Touched:connect(function(part)
  281. if part:IsDescendantOf(Tool.Parent) then return end
  282. if contains(Knives, part) then return end
  283.  
  284. if part.Parent and part.Parent:FindFirstChild("Humanoid") then
  285. local human = part.Parent.Humanoid
  286. if checkTeams(human) then
  287. tagHuman(human)
  288. human:TakeDamage(damage)
  289. knife.Hit:Play()
  290. end
  291. end
  292.  
  293. knife.Projectile:Destroy()
  294.  
  295. local w = Instance.new("Weld")
  296. w.Part0 = part
  297. w.Part1 = knife
  298. w.C0 = part.CFrame:toObjectSpace(knife.CFrame)
  299. w.Parent = w.Part0
  300.  
  301. touched:disconnect()
  302. end)
  303. table.insert(Knives, knife)
  304. knife.Parent = workspace
  305.  
  306. game:GetService("Debris"):AddItem(knife, 3.5)
  307. delay(2, function()
  308. knife.Transparency = 1
  309. end)
  310.  
  311. Remote:FireClient(getPlayer(), "PlayAnimation", "Throw")
  312.  
  313. Handle.Throw.Pitch = 0.8 + 0.4 * AttackPower
  314. Handle.Throw:Play()
  315.  
  316. AttackPower = 0
  317. end
  318.  
  319. function onRemote(player, func, ...)
  320. if player ~= getPlayer() then return end
  321.  
  322. if func == "LeftDown" then
  323. onLeftDown(...)
  324. end
  325. end
  326.  
  327. function onEquip()
  328. Equipped = true
  329. equippedLoop()
  330. end
  331.  
  332. function onUnequip()
  333. Equipped = false
  334. end
  335.  
  336. Remote.OnServerEvent:connect(onRemote)
  337. Tool.Equipped:connect(onEquip)
  338. Tool.Unequipped:connect(onUnequip)
  339. end))
  340. LocalScript14.Name = "Client"
  341. LocalScript14.Parent = Tool12
  342. table.insert(cors,sandbox(LocalScript14,function()
  343. local Player = game:GetService("Players").LocalPlayer
  344. local UIS = game:GetService("UserInputService")
  345. local Mouse = Player:GetMouse()
  346. local Tool = script.Parent
  347. local Remote = Tool:WaitForChild("Remote")
  348. local Tracks = {}
  349. local InputType = Enum.UserInputType
  350.  
  351. local BeganConnection, EndedConnection
  352.  
  353. function playAnimation(animName, ...)
  354. if Tracks[animName] then
  355. Tracks[animName]:Play()
  356. else
  357. local anim = Tool:FindFirstChild(animName)
  358. if anim and Tool.Parent and Tool.Parent:FindFirstChild("Humanoid") then
  359. Tracks[animName] = Tool.Parent.Humanoid:LoadAnimation(anim)
  360. playAnimation(animName, ...)
  361. end
  362. end
  363. end
  364.  
  365. function stopAnimation(animName)
  366. if Tracks[animName] then
  367. Tracks[animName]:Stop()
  368. end
  369. end
  370.  
  371. function inputBegan(input)
  372. if input.UserInputType == InputType.MouseButton1 then
  373. Remote:FireServer("LeftDown", Mouse.Hit.p)
  374. end
  375. end
  376.  
  377. function inputEnded(input)
  378. if input.UserInputType == InputType.MouseButton1 then
  379. Remote:FireServer("LeftUp")
  380. end
  381. end
  382.  
  383. function onRemote(func, ...)
  384. if func == "PlayAnimation" then
  385. playAnimation(...)
  386. elseif func == "StopAnimation" then
  387. stopAnimation(...)
  388. end
  389. end
  390.  
  391. function onEquip()
  392. BeganConnection = UIS.InputBegan:connect(inputBegan)
  393. EndedConnection = UIS.InputEnded:connect(inputEnded)
  394. end
  395.  
  396. function onUnequip()
  397. if BeganConnection then
  398. BeganConnection:disconnect()
  399. BeganConnection = nil
  400. end
  401.  
  402. if EndedConnection then
  403. EndedConnection:disconnect()
  404. EndedConnection = nil
  405. end
  406. end
  407.  
  408. Tool.Equipped:connect(onEquip)
  409. Tool.Unequipped:connect(onUnequip)
  410. Remote.OnClientEvent:connect(onRemote)
  411. end))
  412. RemoteEvent15.Name = "Remote"
  413. RemoteEvent15.Parent = Tool12
  414. Animation16.Name = "Throw"
  415. Animation16.Parent = Tool12
  416. Animation16.AnimationId = "http://www.roblox.com/asset/?id=207107855"
  417. Part17.Name = "Handle"
  418. Part17.Parent = Tool12
  419. Part17.Rotation = Vector3.new(90, 0, 0)
  420. Part17.CanCollide = false
  421. Part17.FormFactor = Enum.FormFactor.Custom
  422. Part17.Size = Vector3.new(2.19999552, 4.39999008, 21.9999542)
  423. Part17.CFrame = CFrame.new(-21.9000015, 65.9999695, -22.8000031, 0.99999994, 0, 0, 0, 2.98023224e-08, -0.999999881, 0, 0.999999881, 2.98023224e-08)
  424. Part17.BottomSurface = Enum.SurfaceType.Smooth
  425. Part17.TopSurface = Enum.SurfaceType.Smooth
  426. Part17.Position = Vector3.new(-21.9000015, 65.9999695, -22.8000031)
  427. Part17.Orientation = Vector3.new(89.9700012, 0, 0)
  428. SpecialMesh18.Parent = Part17
  429. SpecialMesh18.MeshId = "rbxassetid://536945307"
  430. SpecialMesh18.Scale = Vector3.new(1.22099745, 1.22099745, 1.22099745)
  431. SpecialMesh18.TextureId = "rbxassetid://536945378"
  432. SpecialMesh18.MeshType = Enum.MeshType.FileMesh
  433. SpecialMesh18.Scale = Vector3.new(1.22099745, 1.22099745, 1.22099745)
  434. Sound19.Name = "Throw"
  435. Sound19.Parent = Part17
  436. Sound19.SoundId = "http://www.roblox.com/asset/?id=97095069"
  437. Sound20.Name = "Hit"
  438. Sound20.Parent = Part17
  439. Sound20.SoundId = "http://www.roblox.com/asset/?id=93706376"
  440. Script21.Name = "Projectile"
  441. Script21.Parent = Tool12
  442. Script21.Disabled = true
  443. table.insert(cors,sandbox(Script21,function()
  444. local Projectile = script.Parent
  445. local Heartbeat = game:GetService("RunService").Heartbeat
  446.  
  447. while Heartbeat:wait() do
  448. Projectile.CFrame = CFrame.new(Projectile.Position, Projectile.Position + Projectile.Velocity)
  449. end
  450.  
  451. end))
  452. for i,v in pairs(mas:GetChildren()) do
  453. v.Parent = workspace
  454. pcall(function() v:MakeJoints() end)
  455. end
  456. mas:Destroy()
  457. for i,v in pairs(cors) do
  458. spawn(function()
  459. pcall(v)
  460. end)
  461. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement