Advertisement
agariogamer2345

Oof knife

Jul 21st, 2018
499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.79 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. Tool0 = Instance.new("Tool")
  20. Part1 = Instance.new("Part")
  21. LocalScript2 = Instance.new("LocalScript")
  22. Sound3 = Instance.new("Sound")
  23. Sound4 = Instance.new("Sound")
  24. SpecialMesh5 = Instance.new("SpecialMesh")
  25. Decal6 = Instance.new("Decal")
  26. Animation7 = Instance.new("Animation")
  27. Animation8 = Instance.new("Animation")
  28. Animation9 = Instance.new("Animation")
  29. Camera10 = Instance.new("Camera")
  30. Tool0.Name = "Murderer's Knife"
  31. Tool0.Parent = mas
  32. Tool0.TextureId = "rbxassetid://394536085"
  33. Tool0.Grip = CFrame.new(-0.132188454, -0.118292309, -0.183755353, -0.999465764, 0.00433513476, -0.0323996544, 0.00573933125, 0.999042571, -0.0433746353, 0.0321805477, -0.0435373336, -0.998533487)
  34. Tool0.GripForward = Vector3.new(0.0323996544, 0.0433746353, 0.998533487)
  35. Tool0.GripPos = Vector3.new(-0.132188454, -0.118292309, -0.183755353)
  36. Tool0.GripRight = Vector3.new(-0.999465764, 0.00573933125, 0.0321805477)
  37. Tool0.GripUp = Vector3.new(0.00433513476, 0.999042571, -0.0435373336)
  38. Tool0.ToolTip = "Stabby wabby :3"
  39. Part1.Name = "Handle"
  40. Part1.Parent = Tool0
  41. Part1.CFrame = CFrame.new(-51.6436462, 3.17445302, -19.7466812, 0, 0.0382429808, -0.999268532, 0, 0.999268532, 0.0382429808, 1, 0, 0)
  42. Part1.Orientation = Vector3.new(-2.19000006, -90, 0)
  43. Part1.Position = Vector3.new(-51.6436462, 3.17445302, -19.7466812)
  44. Part1.Rotation = Vector3.new(-90, -87.8099976, -90)
  45. Part1.Color = Color3.new(0.388235, 0.372549, 0.384314)
  46. Part1.Size = Vector3.new(0.200000003, 3.9199934, 0.829999506)
  47. Part1.BottomSurface = Enum.SurfaceType.Smooth
  48. Part1.BrickColor = BrickColor.new("Dark stone grey")
  49. Part1.TopSurface = Enum.SurfaceType.Smooth
  50. Part1.brickColor = BrickColor.new("Dark stone grey")
  51. Part1.FormFactor = Enum.FormFactor.Custom
  52. Part1.formFactor = Enum.FormFactor.Custom
  53. LocalScript2.Name = "MacheteScript"
  54. LocalScript2.Parent = Part1
  55. table.insert(cors,sandbox(LocalScript2,function()
  56. ------------------------
  57. --[[UTIL Functions]]--
  58. ------------------------
  59. --Global functions used by all classes are wrapped in UTIL
  60. --deal with it.
  61. local UTIL = {}
  62.  
  63. function UTIL.Class(tableIn,template)
  64. tableIn = tableIn or {}
  65. local mt = {
  66. __metatable = UTIL.DeepCopy(template);
  67. __index = UTIL.DeepCopy(template);
  68. }
  69. return setmetatable(tableIn, mt)
  70. end
  71. function UTIL.MakeClass(...)
  72. local arg = {...}
  73. assert(#arg>0, 'ERROR: class needs 1 argument or more')
  74. local members = arg[1]
  75. for i=2,#arg,1 do
  76. if type(arg[i])=='table' then
  77. for key,val in pairs(arg[i]) do
  78. if not members[key] then
  79. members[key] = val
  80. end
  81. end
  82. end
  83. end
  84. local function New(init)
  85. return UTIL.Class(init or {},members)
  86. end
  87. local function Copy(obj, ...)
  88. local newobj = obj:New(unpack(arg))
  89. for n,v in pairs(obj) do newobj[n] = v end
  90. return newobj
  91. end
  92. members.New = New
  93. members.Copy = Copy
  94. return mt
  95. end
  96.  
  97. function UTIL.DeepCopy(orig)
  98. local orig_type = type(orig)
  99. local copy
  100. if orig_type == 'table' then
  101. copy = {}
  102. for orig_key, orig_value in next, orig, nil do
  103. copy[UTIL.DeepCopy(orig_key)] = UTIL.DeepCopy(orig_value)
  104. end
  105. setmetatable(copy, UTIL.DeepCopy(getmetatable(orig)))
  106. else -- number, string, boolean, etc
  107. copy = orig
  108. end
  109. return copy
  110. end
  111.  
  112. function UTIL.Instantiate(guiType)
  113. return function(data)
  114. local obj = Instance.new(guiType)
  115. for k, v in pairs(data) do
  116. if type(k) == 'number' then
  117. v.Parent = obj
  118. else
  119. obj[k] = v
  120. end
  121. end
  122. return obj
  123. end
  124. end
  125.  
  126. function UTIL.RetroRegister(func,...)
  127. func()
  128. for _,i in ipairs({...}) do
  129. i:connect(func)
  130. end
  131. end
  132.  
  133. -- Waits for a new character to be added if the current one is invalid
  134. -- (Ensures that you don't have the old dead character after a respawn)
  135. function UTIL.WaitForValidCharacter(player)
  136. local character = player.Character
  137. if not character or not character.Parent or not character:FindFirstChild('Humanoid') or character.Humanoid.Health <= 0 then
  138. player.CharacterAdded:wait()
  139. wait(0) --NOTE: Necessary for server scripts executing on the same event
  140. character = player.Character
  141. end
  142. return character
  143. end
  144.  
  145.  
  146. -- Returns a character ancestor and its Humanoid, or nil
  147. function UTIL.FindCharacterAncestor(subject)
  148. if subject and subject ~= Workspace then
  149. local humanoid = subject:FindFirstChild('Humanoid')
  150. if humanoid then
  151. return subject, humanoid
  152. else
  153. return UTIL.FindCharacterAncestor(subject.Parent)
  154. end
  155. end
  156. return nil
  157. end
  158.  
  159. UTIL.AssetURL = 'http://www.roblox.com/asset/?id='
  160.  
  161.  
  162. UTIL.TouchEnabled = game:GetService("UserInputService").TouchEnabled
  163. do
  164. local suceeded,_ =pcall(function() game.Workspace.CurrentCamera:GetPanSpeed() end)
  165. UTIL.CanCheckPanSpeed = suceeded
  166. end
  167.  
  168.  
  169. local DebrisService = Game:GetService('Debris')
  170. local DebugPrintOffset = 0
  171. function UTIL.Dprint(...)
  172. local line = ''
  173. for _, segment in pairs({...}) do
  174. line = line .. (line and ' ' or '') .. tostring(segment)
  175. end
  176. local gui = Instance.new('ScreenGui')
  177. local label = Instance.new('TextLabel')
  178. label.Text = line
  179. label.Size = UDim2.new(0.25, 0, 0.05, 0)
  180. label.BackgroundTransparency = 0.5
  181. label.Position = UDim2.new(0, 0, 0, DebugPrintOffset)
  182. label.TextWrapped = true
  183. label.Parent = gui
  184. DebrisService:AddItem(gui, 30)
  185. gui.Parent = script.Parent
  186. DebugPrintOffset = (DebugPrintOffset <= 600) and DebugPrintOffset + 30 or 0
  187. end
  188. --
  189. --All Welding Related Utility functions should be put here
  190. --
  191. WeldUtil = {}
  192.  
  193.  
  194. do
  195.  
  196.  
  197. function WeldUtil.WeldBetween(a, b)
  198. local weld = Instance.new("Weld")
  199. weld.Part0 = a
  200. weld.Part1 = b
  201. weld.C0 = CFrame.new()
  202. weld.C1 = b.CFrame:inverse() * a.CFrame
  203.  
  204. weld.Parent = a
  205. return weld
  206. end
  207.  
  208. function WeldUtil:PermaWeld(weld)
  209. local OriginalParent = weld.Parent
  210. weld.Changed:connect(function()
  211. Delay(0,function() weld.Parent = OriginalParent end)
  212. end)
  213. end
  214.  
  215. end
  216.  
  217. local InternalEvent =
  218. {
  219. Listeners = nil,
  220. }
  221. do
  222. UTIL.MakeClass(InternalEvent)
  223. function InternalEvent:Connect(func)
  224. if not self.Listeners then self.Listeners = {} end
  225. table.insert(self.Listeners,func)
  226. end
  227. function InternalEvent:Fire(...)
  228. if not self.Listeners then return end
  229. local args = {...}
  230. for _,i in ipairs(self.Listeners) do
  231. Spawn(function() i(unpack(args)) end)
  232. end
  233. end
  234. end
  235.  
  236. --[[Sword Part Class]]--
  237.  
  238. local SwordPart =
  239. {
  240. Damage = 50,
  241. AttackTime = 0.5,
  242. CoolDown = 0,
  243.  
  244. LastSwing = 0,
  245. LastHit = 0,
  246.  
  247. Part= nil,
  248. Owner = nil,--player object that owns this sword
  249.  
  250. OnHit = nil,
  251. OnHitHumanoid = nil,
  252. OnAttackReady = nil,
  253. OnAttack = nil,
  254.  
  255.  
  256. SwingSound = nil,
  257. HitSound = nil,
  258. SwingAnimation = nil, --animation track!
  259.  
  260. ActiveConnections = {},
  261.  
  262. }
  263. do
  264. UTIL.MakeClass(SwordPart)
  265. function SwordPart.New(npart,nowner)
  266. local init= UTIL.DeepCopy(SwordPart)
  267. init.Part= npart
  268. init.Owner = nowner
  269. table.insert(init.ActiveConnections,init.Part.Touched:connect(function(hit) init:SwordTouch(hit) end))
  270.  
  271. init.OnHit = InternalEvent.New()
  272. init.OnHitHumanoid = InternalEvent.New()
  273. init.OnAttackReady = InternalEvent.New()
  274. init.OnAttack = InternalEvent.New()
  275.  
  276. return init
  277. end
  278.  
  279. function SwordPart:SwordTouch(hit)
  280. if tick()-self.LastSwing >self.AttackTime or tick()-self.LastHit<self.AttackTime then return end
  281. self.OnHit:Fire(hit)
  282. local character,humanoid = UTIL.FindCharacterAncestor(hit)
  283. if character and character ~= self.Owner.Character then
  284. humanoid:TakeDamage(self.Damage)
  285. self.OnHitHumanoid:Fire(humanoid,hit)
  286. self.LastHit = tick()
  287. if self.HitSound then
  288. self.HitSound:Play()
  289. end
  290. end
  291.  
  292. end
  293.  
  294. function SwordPart:DoSwing()
  295. if tick()-self.LastSwing<self.AttackTime+self.CoolDown then
  296. return
  297. end
  298.  
  299. if self.SwingAnimation then
  300. self.SwingAnimation:Play()
  301. end
  302. if self.SwingSound then
  303. self.SwingSound:Play()
  304. end
  305. self.LastSwing = tick()
  306. self.OnAttack:Fire()
  307. end
  308.  
  309. function SwordPart:Destroy()
  310. for _,i in pairs(self.ActiveConnections) do
  311. i:disconnect()
  312. end
  313. end
  314. end
  315. do
  316. local Handle = script.Parent
  317. local Tool = Handle.Parent
  318.  
  319. local Player = game.Players.LocalPlayer
  320. local Character = UTIL.WaitForValidCharacter(Player)
  321. local SwingAni = UTIL.Instantiate"Animation"
  322. {AnimationId = "http://www.roblox.com/Asset?ID=89289879"}
  323.  
  324. local HitSound = Handle:WaitForChild('Hit')
  325. local SwingSound = Handle:WaitForChild('Swing')
  326.  
  327. local SwingAniTrack
  328.  
  329. local Sword
  330.  
  331.  
  332. Tool.Equipped:connect(function(mouse)
  333. Sword = SwordPart.New(Handle,Player)
  334. Sword.Damage = 40
  335. Sword.HitSound = HitSound
  336. Sword.SwingSound = SwingSound
  337. Character = UTIL.WaitForValidCharacter(Player)
  338. local Humanoid = Character:FindFirstChild('Humanoid')
  339.  
  340. SwingAniTrack = Humanoid:LoadAnimation(SwingAni)
  341. Sword.SwingAnimation = SwingAniTrack
  342.  
  343. Sword.OnHitHumanoid:Connect(function(humanoid,hit)
  344. local myTorso = Character:FindFirstChild('Torso')
  345. local torso = humanoid.Parent:FindFirstChild('Torso')
  346. if not torso or not myTorso then return end
  347.  
  348. if hit.Name=='Right Arm' or hit.Name=='Left Arm' or hit.Name=='Right Leg' or hit.Name=='Left Leg' then
  349. hit:BreakJoints()
  350. WeldUtil.WeldBetween(hit, Handle)
  351. Delay(1,function() hit:BreakJoints() end )
  352. end
  353. end)
  354.  
  355. mouse.Button1Down:connect(function()
  356. Sword:DoSwing()
  357. end)
  358. end)
  359. Tool.Unequipped:connect(function()
  360. Sword:Destroy()
  361. end)
  362.  
  363. end
  364.  
  365. end))
  366. Sound3.Name = "Hit"
  367. Sound3.Parent = Part1
  368. Sound3.SoundId = "http://www.roblox.com/Asset?ID=123252378"
  369. Sound3.Volume = 1
  370. Sound4.Name = "Swing"
  371. Sound4.Parent = Part1
  372. Sound4.SoundId = "http://www.roblox.com/Asset?ID=119888724"
  373. Sound4.Volume = 1
  374. SpecialMesh5.Parent = Part1
  375. SpecialMesh5.MeshId = "rbxassetid://1553262626"
  376. SpecialMesh5.TextureId = "rbxassetid://1553262651"
  377. SpecialMesh5.MeshType = Enum.MeshType.FileMesh
  378. Decal6.Parent = Part1
  379. Decal6.Texture = "http://www.roblox.com/asset/?id=116830967"
  380. Decal6.Face = Enum.NormalId.Left
  381. Animation7.Name = "ShieldWalk"
  382. Animation7.Parent = Tool0
  383. Animation7.AnimationId = "http://www.roblox.com/Asset?ID=49763871"
  384. Animation8.Name = "QuickSlash"
  385. Animation8.Parent = Tool0
  386. Animation8.AnimationId = "http://www.roblox.com/Asset?ID=49815113"
  387. Animation9.Name = "ShieldBash"
  388. Animation9.Parent = Tool0
  389. Animation9.AnimationId = "http://www.roblox.com/Asset?ID=49907410"
  390. Camera10.Name = "ThumbnailCamera"
  391. Camera10.Parent = Tool0
  392. Camera10.CFrame = CFrame.new(10.8518162, 26.3124142, 50.5024376, -0.900446653, 0.0163968559, 0.434657425, 9.31322464e-10, 0.999289393, -0.0376968235, -0.434966534, -0.0339439772, -0.899806678)
  393. Camera10.CoordinateFrame = CFrame.new(10.8518162, 26.3124142, 50.5024376, -0.900446653, 0.0163968559, 0.434657425, 9.31322464e-10, 0.999289393, -0.0376968235, -0.434966534, -0.0339439772, -0.899806678)
  394. Camera10.FieldOfView = 9.999999825821
  395. Camera10.Focus = CFrame.new(9.98250103, 26.3878078, 52.3020515, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  396. Camera10.focus = CFrame.new(9.98250103, 26.3878078, 52.3020515, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  397. for i,v in pairs(mas:GetChildren()) do
  398. v.Parent = game:GetService("Players").LocalPlayer.Backpack
  399. pcall(function() v:MakeJoints() end)
  400. end
  401. mas:Destroy()
  402. for i,v in pairs(cors) do
  403. spawn(function()
  404. pcall(v)
  405. end)
  406. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement