Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.94 KB | None | 0 0
  1. local tool=Instance.new("HopperBin", game.Players.LocalPlayer.Backpack)
  2. tool.Name="Knife"
  3.  
  4. wait()
  5. script.Parent=tool
  6.  
  7. --Murderer knife action script, original code from The Mad Murderer, by loleris.
  8.  
  9. wait()
  10. local camera = game.Workspace.CurrentCamera
  11. local player = game.Players.LocalPlayer
  12. local character = player.Character
  13. local humanoid = character.Humanoid
  14. local head = character.Head
  15. local torso = character.Torso
  16. local pl_mouse = player:GetMouse()
  17.  
  18. local rs = game:GetService("RunService")
  19.  
  20. local stab_damage = 110
  21. local walkspeeds = {16, 19}
  22.  
  23. Settings = {
  24. Equip_time = 0.4,
  25. Idle_speed = 5,
  26. Attack_speed = 0.65,
  27. }
  28.  
  29. local assetlink = "http://www.roblox.com/asset/?id="
  30. local hit_sounds = {"437475935", "437475935", "437475935", "437475935"}
  31. local death_sounds = {"406913243", "406913243", "406913243"}
  32. function Clean(obj)
  33. spawn(function()
  34. wait(6)
  35. obj:remove()
  36. end)
  37. end
  38.  
  39. function HIT_HANDLE(hit, dmg, pos)
  40. if hit == nil then return end
  41. local h = hit.Parent:findFirstChild("Humanoid")
  42. if h == nil then
  43. h = hit.Parent.Parent:findFirstChild("Humanoid")
  44. end
  45. if h == nil then return end
  46. if h.Health <= 0 then return end
  47.  
  48. local head = h.Parent:findFirstChild("Head")
  49. if head == nil then return end
  50.  
  51. local sound_part = Instance.new("Part")
  52. sound_part.formFactor = "Custom"
  53. sound_part.Size = Vector3.new(0.2, 0.2, 0.2)
  54. sound_part.Transparency = 1
  55. sound_part.CanCollide = false
  56. sound_part.Anchored = true
  57. sound_part.CFrame = head.CFrame
  58. Clean(sound_part)
  59. sound_part.Parent = Workspace
  60. local s_hit = Instance.new("Sound")
  61. s_hit.Volume = 1
  62. s_hit.SoundId = assetlink .. hit_sounds[math.random(1, #hit_sounds)]
  63. s_hit.Parent = sound_part
  64. local s_die = Instance.new("Sound")
  65. s_die.Volume = 1
  66. s_die.SoundId = assetlink .. death_sounds[math.random(1, #death_sounds)]
  67. s_die.Parent = sound_part
  68.  
  69. s_hit:play()
  70.  
  71. local c_tag = Instance.new("ObjectValue")
  72. c_tag.Name = "creator"
  73. c_tag.Value = player
  74. c_tag.Parent = h
  75. h.Health=0
  76. s_die:play()
  77. end
  78.  
  79. function GENERATE_IGNORELIST()
  80. local result = {character, camera}
  81. local plr = game.Players:GetPlayers()
  82. for i = 1, #plr do
  83. if plr[i] ~= player then
  84. local char = plr[i].Character
  85. if char ~= nil then
  86. local ch = char:GetChildren()
  87. for i = 1, #ch do
  88. if ch[i]:IsA("Hat") or ch[i]:IsA("Tool") then
  89. result[#result + 1] = ch[i]
  90. end
  91. end
  92. end
  93. end
  94. end
  95. return result
  96. end
  97.  
  98. function RayCast(pos1, pos2, dist, ign)
  99. local ray = Ray.new(
  100. pos1,
  101. (pos2 - pos1).unit * math.abs(dist)
  102. )
  103. local hit, hpos = Workspace:FindPartOnRayWithIgnoreList(ray, ign, false)
  104. return hit, hpos
  105. end
  106.  
  107. local larm = character:findFirstChild("Left Arm")
  108. local rarm = character:findFirstChild("Right Arm")
  109. function Slash(del)
  110. coroutine.resume(coroutine.create(function()
  111. local hits = {}
  112.  
  113. local start = tick()
  114. local actv = true
  115.  
  116. local function ishitted(obj)
  117. for i = 1, #hits do
  118. if obj:IsDescendantOf(hits[i]) then
  119. return true
  120. end
  121. end
  122. return false
  123. end
  124.  
  125. local function hitp(hit)
  126. if ishitted(hit) then return end
  127. local h = hit.Parent:findFirstChild("Humanoid")
  128. if h == nil then
  129. h = hit.Parent.Parent:findFirstChild("Humanoid")
  130. end
  131. if h == nil then return end
  132. hits[#hits + 1] = h.Parent
  133. HIT_HANDLE(hit, stab_damage)
  134. end
  135.  
  136. local con = {
  137. larm.Touched:connect(hitp),
  138. rarm.Touched:connect(hitp),
  139. }
  140.  
  141. while tick() - start <= Settings.Attack_speed do wait() end
  142. actv = false
  143. con[1]:disconnect()
  144. con[2]:disconnect()
  145. end))
  146. end
  147.  
  148. local dg_sounds = {
  149. equip = {
  150. "342274063"
  151. },
  152. hit = {
  153. "406913243",
  154. "406913243",
  155. "406913243",
  156. "406913243"
  157. },
  158. swing = {
  159. "437475935",
  160. "437475935",
  161. "437475935",
  162. "437475935"
  163. }
  164. }
  165.  
  166. local dg_soundobj = {}
  167. for k, v in pairs(dg_sounds) do
  168. dg_soundobj[k] = {}
  169. for i = 1, #v do
  170. local ns = Instance.new("Sound")
  171. ns.SoundId = assetlink .. v[i]
  172. ns.Volume = 1
  173. dg_soundobj[k][#dg_soundobj[k] + 1] = ns
  174. end
  175. end
  176.  
  177. function LoadSounds()
  178. for __, v in pairs(dg_soundobj) do
  179. for i = 1, #v do
  180. v[i].Parent = head
  181. end
  182. end
  183. end
  184. function RemoveSounds()
  185. for __, v in pairs(dg_soundobj) do
  186. for i = 1, #v do
  187. v[i].Parent = nil
  188. end
  189. end
  190. end
  191. function PlaySound(nm, dl)
  192. if dl == nil then
  193. dg_soundobj[nm][math.random(1, #dg_soundobj[nm])]:play()
  194. else
  195. coroutine.resume(coroutine.create(function()
  196. wait(dl)
  197. dg_soundobj[nm][math.random(1, #dg_soundobj[nm])]:play()
  198. end))
  199. end
  200. end
  201.  
  202. _G.MurderKnife_AnimType = "Default"
  203. _G.MurderKnife_AnimState = 0
  204.  
  205. function Animate(tp, st)
  206. _G.MurderKnife_AnimType = tp
  207. _G.MurderKnife_AnimState = st
  208. end
  209.  
  210. tool.Selected:connect(function(mouse) --Default, Idle1, Idle2, Attack1, Attack2
  211. humanoid.WalkSpeed = walkspeeds[2]
  212. mouse.Icon = assetlink .. "54019936"
  213. Animate("Equip", 0)
  214. LoadSounds()
  215. if not asound then
  216. asound=Instance.new("Sound", character)
  217. asound.SoundId="rbxassetid://342274063"
  218. asound.Volume=1
  219. asound.Looped=true
  220. asound:Play()
  221. else
  222. asound:Resume()
  223. end
  224.  
  225. local anim_equip = 1
  226. local last_action = tick()
  227. local idle_rand = math.random(4, 7)
  228. local idle_perform = 0
  229. local idle_type = 1
  230.  
  231. local attack_perform = 0
  232. local attack_type = 1
  233.  
  234. local running = true
  235. local last_c = tick()
  236.  
  237. local click_start = tick()
  238. mouse.Button1Down:connect(function()
  239. if not running or anim_equip > 0 then return end
  240. if tick() - attack_perform <= Settings.Attack_speed then return end
  241. attack_perform = tick()
  242. last_action = tick()
  243. attack_type = math.random(1, 3)
  244. idle_perform = 0
  245. PlaySound("swing", 0.15)
  246. Slash(0.17)
  247. end)
  248.  
  249. local conn = rs.RenderStepped:connect(function()
  250. if not running then return end
  251. local delta = tick() - last_c
  252. last_c = tick()
  253.  
  254. if anim_equip > 0 then
  255. anim_equip = math.max(0, anim_equip - (delta / Settings.Equip_time))
  256. Animate("Equip", 1 - anim_equip)
  257. elseif tick() - attack_perform <= Settings.Attack_speed then
  258. Animate("Attack" .. attack_type, (tick() - attack_perform) / Settings.Attack_speed)
  259. idle_perform = 0
  260. elseif tick() - idle_perform <= Settings.Idle_speed then
  261. Animate("Idle" .. idle_type, (tick() - idle_perform) / Settings.Idle_speed)
  262. else
  263. Animate("Default", 0)
  264. end
  265.  
  266. if tick() - last_action >= idle_rand then
  267. idle_rand = math.random(12, 20)
  268. last_action = tick()
  269. idle_perform = tick()
  270. idle_type = math.random(1, 2)
  271. end
  272.  
  273. end)
  274. tool.Deselected:connect(function() running = false conn:disconnect() end)
  275. end)
  276. tool.Deselected:connect(function()
  277. RemoveSounds()
  278. humanoid.WalkSpeed = walkspeeds[1]
  279. end)
  280.  
  281. --Murderer knife animation module, original code from The Mad Murderer, by loleris.
  282.  
  283. local mouse = pl_mouse
  284.  
  285. local conn_type = "Snap"
  286.  
  287. local anim_head = false
  288.  
  289. weapon_properties = {
  290. mesh_id = "http://www.roblox.com/asset/?id=121944778",
  291. texture_id = "http://www.roblox.com/asset/?id=121944805",
  292. scale = Vector3.new(0.6, 0.6, 0.6),
  293. transparency = 0,
  294. reflectance = 0,
  295. brick_color = BrickColor.new("Really black"),
  296. }
  297.  
  298. --How did I make all of this? Magic. Didn't even need an animation editor :)
  299. Animations = {
  300. Default = {
  301. {{}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)}
  302. },
  303. Equip = {
  304. {{}, 0, CFrame.new(0, 0, 0) * CFrame.Angles(-1.571, 0, 0), CFrame.new(0, 0, 0) * CFrame.Angles(-1.571, 0, 0), CFrame.new(0, -1.3, -0.5) * CFrame.Angles(-2.618, 0, 0)},
  305. {{0.8, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.524, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(0, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  306. {{0.2, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  307. },
  308. Idle1 = {
  309. {{}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  310. {{0.3, 2}, 0, CFrame.new(0.8, -0.301, 0.2) * CFrame.Angles(-0.35, 0, 0.872), CFrame.new(-0.201, 0, 0) * CFrame.Angles(0.523, 1.221, -0.699), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 1.221, 0)},
  311. {{0.55, 2}, 0, CFrame.new(0.2, -0.5, 0.2) * CFrame.Angles(-0.14, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(0, 1.221, -0.175), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.746, 1.221, 0.174)},
  312. {{0.15, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  313. },
  314. Idle2 = {
  315. {{}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  316. {{0.3, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.524, 0, 0.872), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, -0.175, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0.523, 0)},
  317. {{0.3, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(0.349, 0, 0.523), CFrame.new(-0.201, 0, 0) * CFrame.Angles(0.174, 0.698, -0.524), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, -1.222, 0)},
  318. {{0.2, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(0.61, 0, 0.349), CFrame.new(-0.201, 0, 0) * CFrame.Angles(0.139, 0.663, -0.489), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, -1.222, 0)},
  319. {{0.2, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)}
  320. },
  321. Attack1 = {
  322. {{}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  323. {{0.25, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-1.048, 0, 0.349), CFrame.new(-0.201, 0, 0) * CFrame.Angles(0.872, 0.349, 0.087), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  324. {{0.15, 2}, 0, CFrame.new(0.4, -0.101, 0.1) * CFrame.Angles(-1.571, 0, -0.35), CFrame.new(-0.301, -0.301, 0.1) * CFrame.Angles(-1.048, -0.175, -0.524), CFrame.new(0, -1.201, -0.801) * CFrame.Angles(-2.095, 0, 0)},
  325. {{0.6, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)}
  326. },
  327. Attack2 = {
  328. {{}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  329. {{0.25, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.699, 0, 0.872), CFrame.new(-0.401, 0.3, 0.1) * CFrame.Angles(1.919, 2.443, -1.222), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  330. {{0.15, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-1.048, 0, -0.524), CFrame.new(-0.5, -0.201, -0.101) * CFrame.Angles(0.523, 1.396, -0.873), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  331. {{0.6, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)}
  332. },
  333. Attack3 = {
  334. {{}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  335. {{0.25, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-1.397, 0, 0.174), CFrame.new(-0.401, -0.201, 0) * CFrame.Angles(1.396, 0.698, -1.571), CFrame.new(0, -1.3, -0.401) * CFrame.Angles(-2.444, 0, 0)},
  336. {{0.15, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-1.397, 0, 0.174), CFrame.new(-0.401, 0.1, 0) * CFrame.Angles(0.349, 2.094, -0.524), CFrame.new(0, -1.3, 0.1) * CFrame.Angles(-3.84, 0, 0)},
  337. {{0.6, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)} --Psst. Create a dummy, try setting position and angles of limbs and the weapon, save CFrame data to code. Easy? Yes. When making a single knife tool, it was all you needed.
  338. }
  339. }
  340.  
  341.  
  342. function CFrameTrans(GetCFrame1, GetCFrame2, GetNumber)
  343. local Diff2 = GetCFrame2.p - GetCFrame1.p
  344. GetCFrame1_s = GetCFrame1 - GetCFrame1.p
  345. GetCFrame2 = GetCFrame2 - GetCFrame2.p
  346. local Diff = GetCFrame1_s:inverse() * GetCFrame2
  347. local x1, y1, z1 = Diff:toEulerAnglesXYZ()
  348. return (GetCFrame1 + (Diff2 * GetNumber)) * CFrame.Angles(x1 * GetNumber, y1 * GetNumber, z1 * GetNumber)
  349. end
  350.  
  351. function TransEff(x, type)
  352. if type == 1 then
  353. return x
  354. elseif type == 2 then
  355. return x*x*(3 - 2*x)
  356. elseif type == 3 then
  357. return math.sin(math.rad(x * 90))
  358. elseif type == 4 then
  359. return 1 - math.sin(math.rad((1 - x) * 90))
  360. end
  361. end
  362.  
  363. function num_trans(n1, n2, x)
  364. return n1 + ((n2 - n1) * x)
  365. end
  366.  
  367. function PlayAnimation(anim_name, tm) --return {left, right, wep, trans}
  368. tm = math.min(1, math.max(0, tm))
  369. local animd = Animations[anim_name]
  370. if #animd == 1 then
  371. return {animd[1][3], animd[1][4], animd[1][5], animd[1][2]}
  372. else
  373. local trans_from = 1
  374. local trans_to = 1
  375. local tm_left = tm
  376. for i = 2, #animd do
  377. tm_left = tm_left - animd[i][1][1]
  378. if tm_left <= 0 then
  379. trans_from = i - 1
  380. trans_to = i
  381. break
  382. end
  383. end
  384. local trans_amm = TransEff((animd[trans_to][1][1] + tm_left) / animd[trans_to][1][1], animd[trans_to][1][2])
  385. return {
  386. CFrameTrans(animd[trans_from][3], animd[trans_to][3], trans_amm),
  387. CFrameTrans(animd[trans_from][4], animd[trans_to][4], trans_amm),
  388. CFrameTrans(animd[trans_from][5], animd[trans_to][5], trans_amm),
  389. num_trans(animd[trans_from][2], animd[trans_to][2], trans_amm)
  390. }
  391. end
  392. end
  393.  
  394. rot_amplitude_head = 20
  395. rot_amplitude_chest = 15
  396.  
  397. anim_p = {
  398. cam_offset = CFrame.new(0.2, -0.37, 0.91) * CFrame.Angles(math.rad(0), math.rad(0), math.rad(0)),
  399. aim_amp = 0.5,
  400. aim_max_change = 4,
  401. aim_retract = 15,
  402. aim_max_deg = 20,
  403. }
  404.  
  405. local weapon_model = Instance.new("Part")
  406. weapon_model.CanCollide = false
  407. weapon_model.Name = "WeaponObject"
  408. weapon_model.formFactor = "Custom"
  409. weapon_model.Size = Vector3.new(0.2, 0.2, 0.2)
  410. weapon_model.TopSurface = 0
  411. weapon_model.BottomSurface = 0
  412. weapon_model.BrickColor = weapon_properties.brick_color
  413. weapon_model.Transparency = weapon_properties.transparency
  414. weapon_model.Reflectance = weapon_properties.reflectance
  415. local mesh = Instance.new("SpecialMesh", weapon_model)
  416. mesh.Scale = weapon_properties.scale
  417. mesh.MeshId = weapon_properties.mesh_id
  418. mesh.TextureId = weapon_properties.texture_id
  419.  
  420. torso = character.Torso
  421. head = character.Head
  422.  
  423. motors = {torso:findFirstChild("Left Shoulder"), torso:findFirstChild("Right Shoulder"), torso:findFirstChild("Neck")}
  424. welds = {nil, nil, nil}
  425. weapon_parts = {weapon_model:clone(), weapon_model:clone()}
  426. weapon_model = nil
  427.  
  428. function EndAnimation()
  429. if motors[1] then
  430. motors[1].Part1 = character:findFirstChild("Left Arm")
  431. end
  432. if motors[2] then
  433. motors[2].Part1 = character:findFirstChild("Right Arm")
  434. end
  435. if motors[3] then
  436. motors[3].Part1 = character:findFirstChild("Head")
  437. end
  438. if welds[1] then
  439. welds[1]:remove()
  440. welds[1] = nil
  441. end
  442. if welds[2] then
  443. welds[2]:remove()
  444. welds[2] = nil
  445. end
  446. if welds[3] then
  447. welds[3]:remove()
  448. welds[3] = nil
  449. end
  450. weapon_parts[1].Parent = nil
  451. if weapon_model then
  452. weapon_model.Parent = nil
  453. end
  454. coroutine.resume(coroutine.create(function()
  455. local swm = weapon_model
  456. wait()
  457. swm.Parent = nil
  458. wait(0.1)
  459. swm.Parent = nil
  460. wait(0.5)
  461. swm.Parent = nil
  462. end))
  463. end
  464.  
  465. local anim_model = Instance.new("Model")
  466. anim_model.Name = "WeaponAnimation"
  467. weapon_model = anim_model
  468.  
  469. local cam_larm = Instance.new("Part")
  470. cam_larm.Parent = anim_model
  471. cam_larm.BrickColor = BrickColor.new("Really black")
  472. cam_larm.formFactor = "Custom"
  473. cam_larm.Size = Vector3.new(0.2, 0.2, 0.2)
  474. cam_larm.TopSurface = 0
  475. cam_larm.BottomSurface = 0
  476. cam_larm.Transparency = 0.4
  477. cam_larm.CanCollide = false
  478. local hmesh = Instance.new("BlockMesh", cam_larm)
  479. hmesh.Scale = Vector3.new(5, 10, 5)
  480.  
  481. local cam_rarm = cam_larm:clone()
  482. cam_rarm.Parent = anim_model
  483.  
  484. function StartAnimation()
  485. local check = {torso:findFirstChild("LeftWeld"), torso:findFirstChild("RightWeld"), torso:findFirstChild("HeadWeld")}
  486. if check[1] then check[1]:remove() end
  487. if check[2] then check[2]:remove() end
  488. if check[3] then check[3]:remove() end
  489. local check2 = {character:findFirstChild("WeaponObject"), camera:findFirstChild("WeaponAnimation")}
  490. if check2[1] then check2[1].Parent = nil end
  491. if check2[2] then check2[2].Parent = nil end
  492. if motors[1] then
  493. motors[1].Part1 = nil
  494. end
  495. if motors[2] then
  496. motors[2].Part1 = nil
  497. end
  498. if motors[3] then
  499. motors[3].Part1 = nil
  500. end
  501. welds = {Instance.new(conn_type), Instance.new(conn_type), Instance.new(conn_type)}
  502. welds[1].Part0 = torso
  503. welds[2].Part0 = torso
  504. welds[3].Part0 = torso
  505. welds[1].Part1 = character:findFirstChild("Left Arm")
  506. welds[2].Part1 = character:findFirstChild("Right Arm")
  507. welds[3].Part1 = character:findFirstChild("Head")
  508. welds[1].Name = "LeftWeld"
  509. welds[2].Name = "RightWeld"
  510. welds[2].Name = "HeadWeld"
  511. welds[1].C0 = CFrame.new(-1.5, 0, 0)
  512. welds[2].C0 = CFrame.new(1.5, 0, 0)
  513. welds[3].C0 = CFrame.new(0, 1.5, 0)
  514. welds[1].Parent = torso
  515. welds[2].Parent = torso
  516. welds[3].Parent = torso
  517.  
  518. weapon_parts[1].Parent = character
  519. local wep_weld = Instance.new(conn_type)
  520. wep_weld.Part0 = character:findFirstChild("Right Arm")
  521. wep_weld.Part1 = weapon_parts[1]
  522. wep_weld.C0 = CFrame.new()
  523. wep_weld.Parent = weapon_parts[1]
  524.  
  525. local weld1 = welds[1]
  526. local weld2 = welds[2]
  527. local weld3 = welds[3]
  528.  
  529. local cam_welds = {Instance.new(conn_type), Instance.new(conn_type), Instance.new(conn_type)}
  530. cam_welds[1].Part0 = torso
  531. cam_welds[1].Part1 = cam_larm
  532. cam_welds[1].Parent = cam_larm
  533. cam_welds[2].Part0 = torso
  534. cam_welds[2].Part1 = cam_rarm
  535. cam_welds[2].Parent = cam_rarm
  536. cam_welds[3].Part0 = cam_rarm
  537. cam_welds[3].Part1 = weapon_parts[2]
  538. cam_welds[3].Parent = weapon_parts[2]
  539. weapon_parts[2].Parent = anim_model
  540.  
  541. local move_anim_speed = 3
  542. local last_p = Vector3.new()
  543. local move_amm = 0
  544. coroutine.resume(coroutine.create(function()
  545. while weld1.Parent ~= nil do
  546. local delta = wait(1/25)
  547. local cur_p = torso.Position
  548. if (cur_p - last_p).magnitude >= 0.1 then
  549. move_amm = math.min(1, move_amm + delta * move_anim_speed)
  550. else
  551. move_amm = math.max(0, move_amm - delta * move_anim_speed)
  552. end
  553. last_p = cur_p
  554. end
  555. end))
  556.  
  557. local r_serv = game:GetService("RunService")
  558.  
  559. --EASTER EGG
  560. function easein(x)
  561. return math.sin(math.rad(x * 90))
  562. end
  563.  
  564. local a_horse = (character:findFirstChild("HorseHead") ~= nil)
  565. local horse_displace = {0, 0}
  566. local horse_cf = CFrame.Angles(0.0001, 0.0001, 0)
  567. if a_horse then
  568. coroutine.resume(coroutine.create(function()
  569. while weld1.Parent ~= nil do
  570. local rndwait = (math.random(100, 1000) / 1000) * 4
  571. wait(rndwait)
  572. local oldd = {horse_displace[1], horse_displace[2]}
  573. local disp2 = {math.random(-60, 60), math.random(0, 25)}
  574.  
  575. local ld = 0
  576. while ld ~= 1 do
  577. local st = tick()
  578. r_serv.RenderStepped:wait()
  579. ld = math.min(1, ld + ((tick() - st) * 4))
  580. local eff = easein(ld)
  581.  
  582. local x = oldd[1] - ((oldd[1] - disp2[1]) * eff)
  583. local y = oldd[2] - ((oldd[2] - disp2[2]) * eff)
  584. horse_displace = {x, y}
  585. horse_cf = CFrame.Angles(math.rad(y), math.rad(x) , 0)
  586. end
  587. end
  588. end))
  589. end
  590.  
  591. --EASTER EGG
  592.  
  593. local last_va = 0
  594. local last_va2 = 0
  595. local view_velocity = {0, 0}
  596.  
  597. coroutine.resume(coroutine.create(function()
  598. local last_time = tick()
  599. while weld1.Parent ~= nil do
  600. r_serv.RenderStepped:wait() ------------------------------------------------
  601. local delta = tick() - last_time
  602. last_time = tick()
  603.  
  604. local breathe_amp = 2
  605. local breathe_freq = 0.8
  606. local breathe = math.sin(math.rad(tick() * 90 * breathe_freq)) * breathe_amp
  607.  
  608. local shake_freq = 5
  609. local shake_amp = {0.05, 0.05}
  610. local arm_shake = CFrame.new(
  611. math.sin(math.rad(tick() * 90 * shake_freq)) * move_amm * shake_amp[1],
  612. 0,
  613. math.abs(math.sin(math.rad(tick() * 90 * shake_freq)) * move_amm * shake_amp[2]))
  614.  
  615.  
  616. --ANIMATION LOOP
  617. local p_distance = (head.Position - mouse.Hit.p).magnitude
  618. if p_distance == 0 then p_distance = 0.0001 end
  619. local p_height = mouse.Hit.p.y - head.Position.y
  620. local view_angle
  621. if p_height ~= 0 then
  622. view_angle = math.deg(math.asin(math.abs(p_height) / p_distance)) * (math.abs(p_height) / p_height)
  623. else
  624. view_angle = 0
  625. end
  626.  
  627. local cam_cf = camera.CoordinateFrame
  628. local looking_at = cam_cf * CFrame.new(0, 0, -100)
  629. local view_angle2 = math.deg(math.atan2(cam_cf.p.x - looking_at.p.x, cam_cf.p.z - looking_at.p.z)) + 180
  630.  
  631. local v_delta1, v_delta2
  632. local dir1 = 0
  633. local dir2 = 0
  634. v_delta1 = math.abs(view_angle - last_va)
  635. if v_delta1 ~= 0 then
  636. dir1 = (view_angle - last_va) / v_delta1
  637. end
  638. local va_check = {math.abs(view_angle2 - last_va2), 360 - math.abs(view_angle2 - last_va2)}
  639. if view_angle2 == last_va2 then
  640. dir2 = 0
  641. v_delta2 = 0
  642. elseif va_check[1] < va_check[2] then
  643. v_delta2 = va_check[1]
  644. dir2 = (view_angle2 - last_va2) / va_check[1]
  645. else
  646. v_delta2 = va_check[2]
  647. if last_va2 > view_angle2 then
  648. dir2 = 1
  649. else
  650. dir2 = -1
  651. end
  652. end
  653. last_va = view_angle
  654. last_va2 = view_angle2
  655.  
  656. view_velocity[1] = view_velocity[1] / (1 + (delta * anim_p.aim_retract))
  657. view_velocity[2] = view_velocity[2] / (1 + (delta * anim_p.aim_retract))
  658.  
  659. local calc1 = v_delta1 * dir1 * anim_p.aim_amp
  660. if calc1 ~= 0 then
  661. view_velocity[1] = view_velocity[1] + (math.min(anim_p.aim_max_change, math.abs(calc1)) * (calc1 / math.abs(calc1)))
  662. end
  663. local calc2 = v_delta2 * dir2 * anim_p.aim_amp
  664. if calc2 ~= 0 then
  665. view_velocity[2] = view_velocity[2] + (math.min(anim_p.aim_max_change, math.abs(calc2)) * (calc2 / math.abs(calc2)))
  666. end
  667.  
  668. if view_velocity[1] ~= 0 then
  669. view_velocity[1] = math.min(anim_p.aim_max_deg, math.abs(view_velocity[1])) * (math.abs(view_velocity[1]) / view_velocity[1])
  670. end
  671. if view_velocity[2] ~= 0 then
  672. view_velocity[2] = math.min(anim_p.aim_max_deg, math.abs(view_velocity[2])) * (math.abs(view_velocity[2]) / view_velocity[2])
  673. end
  674.  
  675. local anmtp = _G.MurderKnife_AnimType
  676. local anmst = _G.MurderKnife_AnimState
  677.  
  678. if anmst == nil then
  679. anmst = 0
  680. end
  681.  
  682. if anmtp ~= nil then
  683. if Animations[anmtp] == nil then
  684. anmtp = "Default"
  685. end
  686. else
  687. anmtp = "Default"
  688. end
  689. local curr_anim = PlayAnimation(anmtp, anmst) --left, right, weapon, wep trans
  690.  
  691. --curr_anim = {Animations.Default[1][3], Animations.Default[1][4], Animations.Default[1][5], 0}
  692.  
  693. local chestCF = CFrame.new(0, 0.5, 0) * CFrame.Angles(math.rad(math.max(-rot_amplitude_chest, math.min(rot_amplitude_chest, view_angle)) + 90 + breathe), 0, 0)
  694. weld1.C1 = (chestCF * curr_anim[1] * CFrame.new(0, -0.5, 0)):inverse()
  695. weld2.C1 = (chestCF * curr_anim[2] * CFrame.new(0, -0.5, 0)):inverse()
  696. wep_weld.C1 = (curr_anim[3]):inverse()
  697. weapon_parts[1].Transparency = curr_anim[4]
  698. if anim_head then
  699. weld3.C1 = (CFrame.new(0, 0, 0) * CFrame.Angles(math.rad(math.max(-rot_amplitude_head, math.min(rot_amplitude_head, view_angle))), 0, 0) * horse_cf):inverse()
  700. else
  701. weld3.C1 = (CFrame.new(0, 0, 0)):inverse()
  702. end
  703.  
  704. if (head.Position - camera.CoordinateFrame.p).magnitude < 3 then
  705. if anim_model.Parent == nil then
  706. anim_model.Parent = camera
  707. end
  708. cam_welds[1].Parent = cam_larm
  709. cam_welds[2].Parent = cam_rarm
  710. cam_welds[3].Parent = weapon_parts[2]
  711. local cam_cf = camera.CoordinateFrame * CFrame.Angles(math.rad(90 + (breathe / 2) - view_velocity[1]), 0, math.rad(view_velocity[2])) * arm_shake * anim_p.cam_offset
  712. cam_welds[1].C1 = (torso.CFrame:inverse() * cam_cf * CFrame.new(-1.5, 0, 0) * curr_anim[1] * CFrame.new(0, -0.5, 0)):inverse()
  713. cam_welds[2].C1 = (torso.CFrame:inverse() * cam_cf * CFrame.new(1.5, 0, 0) * curr_anim[2] * CFrame.new(0, -0.5, 0)):inverse()
  714. cam_welds[3].C1 = (curr_anim[3]):inverse()
  715. weapon_parts[2].Transparency = curr_anim[4]
  716. else
  717. if anim_model.Parent ~= nil then
  718. anim_model.Parent = nil
  719. end
  720. end
  721. --ANIMATION LOOP
  722. end
  723. end))
  724. end
  725.  
  726. local last_st = 0
  727. local eq = false
  728. tool.Selected:connect(function(mouse)
  729. if eq then return end
  730. eq = true
  731. wait()
  732. StartAnimation()
  733. humanoid.WalkSpeed=humanoid.WalkSpeed+34
  734. end)
  735.  
  736. tool.Deselected:connect(function()
  737. asound:Pause()
  738. eq = false
  739. EndAnimation()
  740. humanoid.WalkSpeed=humanoid.WalkSpeed-34
  741. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement