Advertisement
00fjg

Untitled

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