Advertisement
Josemmoya

not a skid anymoar

Feb 18th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.95 KB | None | 0 0
  1. -- This script has been converted to FE by iPxter
  2.  
  3.  
  4. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  5. local Player,Mouse,mouse,UserInputService,ContextActionService = owner
  6. do
  7. print("FE Compatibility code by Mokiros | Translated to FE by iPxter")
  8. script.Parent = Player.Character
  9.  
  10. --RemoteEvent for communicating
  11. local Event = Instance.new("RemoteEvent")
  12. Event.Name = "UserInput_Event"
  13.  
  14. --Fake event to make stuff like Mouse.KeyDown work
  15. local function fakeEvent()
  16. local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
  17. t.connect = t.Connect
  18. return t
  19. end
  20.  
  21. --Creating fake input objects with fake variables
  22. local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  23. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  24. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  25. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  26. end}
  27. --Merged 2 functions into one by checking amount of arguments
  28. CAS.UnbindAction = CAS.BindAction
  29.  
  30. --This function will trigger the events that have been :Connect()'ed
  31. local function te(self,ev,...)
  32. local t = m[ev]
  33. if t and t._fakeEvent and t.Function then
  34. t.Function(...)
  35. end
  36. end
  37. m.TrigEvent = te
  38. UIS.TrigEvent = te
  39.  
  40. Event.OnServerEvent:Connect(function(plr,io)
  41. if plr~=Player then return end
  42. if io.isMouse then
  43. m.Target = io.Target
  44. m.Hit = io.Hit
  45. else
  46. local b = io.UserInputState == Enum.UserInputState.Begin
  47. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  48. return m:TrigEvent(b and "Button1Down" or "Button1Up")
  49. end
  50. for _,t in pairs(CAS.Actions) do
  51. for _,k in pairs(t.Keys) do
  52. if k==io.KeyCode then
  53. t.Function(t.Name,io.UserInputState,io)
  54. end
  55. end
  56. end
  57. m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  58. UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  59. end
  60. end)
  61. Event.Parent = NLS([==[
  62. local Player = game:GetService("Players").LocalPlayer
  63. local Event = script:WaitForChild("UserInput_Event")
  64.  
  65. local UIS = game:GetService("UserInputService")
  66. local input = function(io,a)
  67. if a then return end
  68. --Since InputObject is a client-side instance, we create and pass table instead
  69. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
  70. end
  71. UIS.InputBegan:Connect(input)
  72. UIS.InputEnded:Connect(input)
  73.  
  74. local Mouse = Player:GetMouse()
  75. local h,t
  76. --Give the server mouse data 30 times every second, but only if the values changed
  77. --If player is not moving their mouse, client won't fire events
  78. while wait(1/30) do
  79. if h~=Mouse.Hit or t~=Mouse.Target then
  80. h,t=Mouse.Hit,Mouse.Target
  81. Event:FireServer({isMouse=true,Target=t,Hit=h})
  82. end
  83. end]==],Player.Character)
  84. Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
  85. end
  86. local AddInstance = function(Object, ...)
  87. local Obj = Instance.new(Object)
  88. for i,v in next,(...) do
  89. Obj[i] = v
  90. end
  91. return Obj
  92. end
  93. local Reaper = AddInstance("Part",{
  94. Parent = owner.Character.Head,
  95. CFrame = owner.Character.Head.CFrame,
  96. formFactor = "Symmetric",
  97. Size = Vector3.new(1, 1, 1),
  98. CanCollide = false,
  99. TopSurface = "Smooth",
  100. BottomSurface = "Smooth",
  101. Locked = true,
  102. })
  103. local Weld = AddInstance("Weld",{
  104. Parent = Reaper,
  105. Part0 = owner.Character.Head,
  106. C0 = CFrame.new(0, 0.1, 0)*CFrame.Angles(0, 0, 0),
  107. Part1 = Reaper,
  108. })
  109. local Mesh = AddInstance("SpecialMesh",{
  110. Parent = Reaper,
  111. MeshId = "rbxassetid://74868480",
  112. TextureId = "rbxassetid://74868480",
  113. Scale = Vector3.new(1.05, 1.5, 1.05),
  114. VertexColor = Vector3.new(0,0,0),
  115. })
  116. for i,v in pairs(owner.Character:GetChildren()) do
  117. if v.ClassName == "Shirt" or v.ClassName == "Pants" or v.ClassName == "ShirtGraphic" then
  118. v:Destroy()
  119. end
  120. end
  121. local shirt = Instance.new("Shirt",char)
  122. shirt.ShirtTemplate = "rbxassetid://166148446"
  123. local pants = Instance.new("Pants",char)
  124. pants.PantsTemplate = "rbxassetid://166148597"
  125. for i,v in pairs(owner.Character:GetChildren()) do
  126. if v.ClassName == "Hat" or v.ClassName == "Accessory" then
  127. v:Destroy()
  128. end
  129. end
  130.  
  131.  
  132.  
  133. local BC = owner.Character["Body Colors"]
  134. BC.HeadColor = BrickColor.new("Institutional white")
  135. BC.LeftArmColor = BrickColor.new("Institutional white")
  136. BC.LeftLegColor = BrickColor.new("Institutional white")
  137. BC.RightArmColor = BrickColor.new("Institutional white")
  138. BC.RightLegColor = BrickColor.new("Institutional white")
  139. BC.TorsoColor = BrickColor.new("Institutional white")
  140. local naeeym2 = Instance.new("BillboardGui",owner.Character)
  141. naeeym2.AlwaysOnTop = true
  142. naeeym2.Size = UDim2.new(5,35,2,35)
  143. naeeym2.StudsOffset = Vector3.new(0,2,0)
  144. naeeym2.Adornee = owner.Character.Head
  145. naeeym2.Name = "Name"
  146.  
  147. local tecks2 = Instance.new("TextLabel",naeeym2)
  148. tecks2.BackgroundTransparency = 1
  149. tecks2.TextScaled = true
  150. tecks2.BorderSizePixel = 0
  151. tecks2.Text = "Darkness"
  152. tecks2.Font = "Fantasy"
  153. tecks2.TextSize = 30
  154. tecks2.TextStrokeTransparency = 0
  155. tecks2.TextColor3 = BrickColor.new('Really black').Color
  156. tecks2.TextStrokeColor3 = BrickColor.new('Blue storm').Color
  157. tecks2.Size = UDim2.new(1,0,0.5,0)
  158. tecks2.Parent = naeeym2
  159. textfag = tecks2
  160. wait(1)
  161. tecks2.Text = "J҉ a҉ c ҉k҉"
  162.  
  163. local tool=Instance.new("HopperBin", owner.Backpack)
  164. tool.Name="Knife"
  165.  
  166. wait()
  167. script.Parent=tool
  168.  
  169. --Jack knife by Josemmoya
  170.  
  171. wait()
  172. local camera = game.Workspace.CurrentCamera
  173. local player = owner
  174. local character = player.Character
  175. local humanoid = character.Humanoid
  176. local head = character.Head
  177. local torso = character.Torso
  178.  
  179. local rs = game:GetService("RunService")
  180.  
  181. local stab_damage = 110
  182. local walkspeeds = {99, 99}
  183.  
  184. Settings = {
  185. Equip_time = 0.4,
  186. Idle_speed = 5,
  187. Attack_speed = 0.65,
  188. }
  189.  
  190. local assetlink = "http://www.roblox.com/asset/?id="
  191. local hit_sounds = {"153647516", "153647519", "153647522", "153647526"}
  192. local death_sounds = {"146594640", "146594648", "146457047"}
  193. function Clean(obj)
  194. spawn(function()
  195. wait(6)
  196. obj:remove()
  197. end)
  198. end
  199.  
  200. function HIT_HANDLE(hit, dmg, pos)
  201. if hit == nil then return end
  202. local h = hit.Parent:findFirstChild("Humanoid")
  203. if h == nil then
  204. h = hit.Parent.Parent:findFirstChild("Humanoid")
  205. end
  206. if h == nil then return end
  207. if h.Health <= 0 then return end
  208.  
  209. local head = h.Parent:findFirstChild("Head")
  210. if head == nil then return end
  211.  
  212. local sound_part = Instance.new("Part")
  213. sound_part.formFactor = "Custom"
  214. sound_part.Size = Vector3.new(0.2, 0.2, 0.2)
  215. sound_part.Transparency = 1
  216. sound_part.CanCollide = false
  217. sound_part.Anchored = true
  218. sound_part.CFrame = head.CFrame
  219. Clean(sound_part)
  220. sound_part.Parent = Workspace
  221. local s_hit = Instance.new("Sound")
  222. s_hit.Volume = 1
  223. s_hit.SoundId = assetlink .. hit_sounds[math.random(1, #hit_sounds)]
  224. s_hit.Parent = sound_part
  225. local s_die = Instance.new("Sound")
  226. s_die.Volume = 1
  227. s_die.SoundId = assetlink .. death_sounds[math.random(1, #death_sounds)]
  228. s_die.Parent = sound_part
  229.  
  230. s_hit:play()
  231.  
  232. local c_tag = Instance.new("ObjectValue")
  233. c_tag.Name = "creator"
  234. c_tag.Value = player
  235. c_tag.Parent = h
  236. h.Health=0
  237. s_die:play()
  238. end
  239.  
  240. function GENERATE_IGNORELIST()
  241. local result = {character, camera}
  242. local plr = game.Players:GetPlayers()
  243. for i = 1, #plr do
  244. if plr[i] ~= player then
  245. local char = plr[i].Character
  246. if char ~= nil then
  247. local ch = owner.Character:GetChildren()
  248. for i = 1, #ch do
  249. if ch[i]:IsA("Hat") or ch[i]:IsA("Tool") then
  250. result[#result + 1] = ch[i]
  251. end
  252. end
  253. end
  254. end
  255. end
  256. return result
  257. end
  258.  
  259. function RayCast(pos1, pos2, dist, ign)
  260. local ray = Ray.new(
  261. pos1,
  262. (pos2 - pos1).unit * math.abs(dist)
  263. )
  264. local hit, hpos = Workspace:FindPartOnRayWithIgnoreList(ray, ign, false)
  265. return hit, hpos
  266. end
  267.  
  268. local larm = character:findFirstChild("Left Arm")
  269. local rarm = character:findFirstChild("Right Arm")
  270. function Slash(del)
  271. coroutine.resume(coroutine.create(function()
  272. local hits = {}
  273.  
  274. local start = tick()
  275. local actv = true
  276.  
  277. local function ishitted(obj)
  278. for i = 1, #hits do
  279. if obj:IsDescendantOf(hits[i]) then
  280. return true
  281. end
  282. end
  283. return false
  284. end
  285.  
  286. local function hitp(hit)
  287. if ishitted(hit) then return end
  288. local h = hit.Parent:findFirstChild("Humanoid")
  289. if h == nil then
  290. h = hit.Parent.Parent:findFirstChild("Humanoid")
  291. end
  292. if h == nil then return end
  293. hits[#hits + 1] = h.Parent
  294. HIT_HANDLE(hit, stab_damage)
  295. end
  296.  
  297. local con = {
  298. larm.Touched:connect(hitp),
  299. rarm.Touched:connect(hitp),
  300. }
  301.  
  302. while tick() - start <= Settings.Attack_speed do wait() end
  303. actv = false
  304. con[1]:disconnect()
  305. con[2]:disconnect()
  306. end))
  307. end
  308.  
  309. local dg_sounds = {
  310. equip = {
  311. "153647514"
  312. },
  313. hit = {
  314. "153647516",
  315. "153647519",
  316. "153647522",
  317. "153647526"
  318. },
  319. swing = {
  320. "153647529",
  321. "153647534",
  322. "153647539",
  323. "153647540"
  324. }
  325. }
  326.  
  327. local dg_soundobj = {}
  328. for k, v in pairs(dg_sounds) do
  329. dg_soundobj[k] = {}
  330. for i = 1, #v do
  331. local ns = Instance.new("Sound")
  332. ns.SoundId = assetlink .. v[i]
  333. ns.Volume = 1
  334. dg_soundobj[k][#dg_soundobj[k] + 1] = ns
  335. end
  336. end
  337.  
  338. function LoadSounds()
  339. for __, v in pairs(dg_soundobj) do
  340. for i = 1, #v do
  341. v[i].Parent = head
  342. end
  343. end
  344. end
  345. function RemoveSounds()
  346. for __, v in pairs(dg_soundobj) do
  347. for i = 1, #v do
  348. v[i].Parent = nil
  349. end
  350. end
  351. end
  352. function PlaySound(nm, dl)
  353. if dl == nil then
  354. dg_soundobj[nm][math.random(1, #dg_soundobj[nm])]:play()
  355. else
  356. coroutine.resume(coroutine.create(function()
  357. wait(dl)
  358. dg_soundobj[nm][math.random(1, #dg_soundobj[nm])]:play()
  359. end))
  360. end
  361. end
  362.  
  363. _G.MurderKnife_AnimType = "Default"
  364. _G.MurderKnife_AnimState = 0
  365.  
  366. function Animate(tp, st)
  367. _G.MurderKnife_AnimType = tp
  368. _G.MurderKnife_AnimState = st
  369. end
  370.  
  371. tool.Selected:connect(function(mouse) --Default, Idle1, Idle2, Attack1, Attack2
  372. humanoid.WalkSpeed = walkspeeds[2]
  373. mouse.Icon = assetlink .. "54019936"
  374. Animate("Equip", 0)
  375. LoadSounds()
  376. PlaySound("equip", 0.1)
  377.  
  378. local anim_equip = 1
  379. local last_action = tick()
  380. local idle_rand = math.random(4, 7)
  381. local idle_perform = 0
  382. local idle_type = 1
  383.  
  384. local attack_perform = 0
  385. local attack_type = 1
  386.  
  387. local running = true
  388. local last_c = tick()
  389.  
  390. local click_start = tick()
  391. mouse.Button1Down:connect(function()
  392. if not running or anim_equip > 0 then return end
  393. if tick() - attack_perform <= Settings.Attack_speed then return end
  394. attack_perform = tick()
  395. last_action = tick()
  396. attack_type = math.random(1, 3)
  397. idle_perform = 0
  398. PlaySound("swing", 0.15)
  399. Slash(0.17)
  400. end)
  401.  
  402. if not running then return end
  403. local delta = tick() - last_c
  404. last_c = tick()
  405.  
  406. if anim_equip > 0 then
  407. anim_equip = math.max(0, anim_equip - (delta / Settings.Equip_time))
  408. Animate("Equip", 1 - anim_equip)
  409. elseif tick() - attack_perform <= Settings.Attack_speed then
  410. Animate("Attack" .. attack_type, (tick() - attack_perform) / Settings.Attack_speed)
  411. idle_perform = 0
  412. elseif tick() - idle_perform <= Settings.Idle_speed then
  413. Animate("Idle" .. idle_type, (tick() - idle_perform) / Settings.Idle_speed)
  414. else
  415. Animate("Default", 0)
  416. end
  417.  
  418. if tick() - last_action >= idle_rand then
  419. idle_rand = math.random(12, 20)
  420. last_action = tick()
  421. idle_perform = tick()
  422. idle_type = math.random(1, 2)
  423.  
  424. end
  425. end)
  426. tool.Deselected:connect(function() running = false conn:disconnect() end)
  427. tool.Deselected:connect(function()
  428. RemoveSounds()
  429. humanoid.WalkSpeed = walkspeeds[1]
  430. end)
  431.  
  432.  
  433.  
  434. local conn_type = "Snap"
  435.  
  436. local anim_head = false
  437.  
  438. weapon_properties = {
  439. mesh_id = "http://www.roblox.com/asset/?id=121944778",
  440. texture_id = "http://www.roblox.com/asset/?id=121944805",
  441. scale = Vector3.new(0.6, 0.6, 0.6),
  442. transparency = 0,
  443. reflectance = 0,
  444. brick_color = BrickColor.new("Really black"),
  445. }
  446.  
  447. --How did I make all of this? Magic. Didn't even need an animation editor :)
  448. Animations = {
  449. Default = {
  450. {{}, 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)}
  451. },
  452. Equip = {
  453. {{}, 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)},
  454. {{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)},
  455. {{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)},
  456. },
  457. Idle1 = {
  458. {{}, 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)},
  459. {{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)},
  460. {{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)},
  461. {{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)},
  462. },
  463. Idle2 = {
  464. {{}, 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)},
  465. {{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)},
  466. {{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)},
  467. {{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)},
  468. {{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)}
  469. },
  470. Attack1 = {
  471. {{}, 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)},
  472. {{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)},
  473. {{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)},
  474. {{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)}
  475. },
  476. Attack2 = {
  477. {{}, 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)},
  478. {{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)},
  479. {{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)},
  480. {{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)}
  481. },
  482. Attack3 = {
  483. {{}, 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)},
  484. {{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)},
  485. {{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)},
  486. {{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.
  487. }
  488. }
  489.  
  490.  
  491. function CFrameTrans(GetCFrame1, GetCFrame2, GetNumber)
  492. local Diff2 = GetCFrame2.p - GetCFrame1.p
  493. GetCFrame1_s = GetCFrame1 - GetCFrame1.p
  494. GetCFrame2 = GetCFrame2 - GetCFrame2.p
  495. local Diff = GetCFrame1_s:inverse() * GetCFrame2
  496. local x1, y1, z1 = Diff:toEulerAnglesXYZ()
  497. return (GetCFrame1 + (Diff2 * GetNumber)) * CFrame.Angles(x1 * GetNumber, y1 * GetNumber, z1 * GetNumber)
  498. end
  499.  
  500. function TransEff(x, type)
  501. if type == 1 then
  502. return x
  503. elseif type == 2 then
  504. return x*x*(3 - 2*x)
  505. elseif type == 3 then
  506. return math.sin(math.rad(x * 90))
  507. elseif type == 4 then
  508. return 1 - math.sin(math.rad((1 - x) * 90))
  509. end
  510. end
  511.  
  512. function num_trans(n1, n2, x)
  513. return n1 + ((n2 - n1) * x)
  514. end
  515.  
  516. function PlayAnimation(anim_name, tm) --return {left, right, wep, trans}
  517. tm = math.min(1, math.max(0, tm))
  518. local animd = Animations[anim_name]
  519. if #animd == 1 then
  520. return {animd[1][3], animd[1][4], animd[1][5], animd[1][2]}
  521. else
  522. local trans_from = 1
  523. local trans_to = 1
  524. local tm_left = tm
  525. for i = 2, #animd do
  526. tm_left = tm_left - animd[i][1][1]
  527. if tm_left <= 0 then
  528. trans_from = i - 1
  529. trans_to = i
  530. break
  531. end
  532. end
  533. local trans_amm = TransEff((animd[trans_to][1][1] + tm_left) / animd[trans_to][1][1], animd[trans_to][1][2])
  534. return {
  535. CFrameTrans(animd[trans_from][3], animd[trans_to][3], trans_amm),
  536. CFrameTrans(animd[trans_from][4], animd[trans_to][4], trans_amm),
  537. CFrameTrans(animd[trans_from][5], animd[trans_to][5], trans_amm),
  538. num_trans(animd[trans_from][2], animd[trans_to][2], trans_amm)
  539. }
  540. end
  541. end
  542.  
  543. rot_amplitude_head = 20
  544. rot_amplitude_chest = 15
  545.  
  546. anim_p = {
  547. cam_offset = CFrame.new(0.2, -0.37, 0.91) * CFrame.Angles(math.rad(0), math.rad(0), math.rad(0)),
  548. aim_amp = 0.5,
  549. aim_max_change = 4,
  550. aim_retract = 15,
  551. aim_max_deg = 20,
  552. }
  553.  
  554. local weapon_model = Instance.new("Part")
  555. weapon_model.CanCollide = false
  556. weapon_model.Name = "WeaponObject"
  557. weapon_model.formFactor = "Custom"
  558. weapon_model.Size = Vector3.new(0.2, 0.2, 0.2)
  559. weapon_model.TopSurface = 0
  560. weapon_model.BottomSurface = 0
  561. weapon_model.BrickColor = weapon_properties.brick_color
  562. weapon_model.Transparency = weapon_properties.transparency
  563. weapon_model.Reflectance = weapon_properties.reflectance
  564. local mesh = Instance.new("SpecialMesh", weapon_model)
  565. mesh.Scale = weapon_properties.scale
  566. mesh.MeshId = weapon_properties.mesh_id
  567. mesh.TextureId = weapon_properties.texture_id
  568.  
  569. torso = character.Torso
  570. head = character.Head
  571.  
  572. motors = {torso:findFirstChild("Left Shoulder"), torso:findFirstChild("Right Shoulder"), torso:findFirstChild("Neck")}
  573. welds = {nil, nil, nil}
  574. weapon_parts = {weapon_model:clone(), weapon_model:clone()}
  575. weapon_model = nil
  576.  
  577. function EndAnimation()
  578. if motors[1] then
  579. motors[1].Part1 = character:findFirstChild("Left Arm")
  580. end
  581. if motors[2] then
  582. motors[2].Part1 = character:findFirstChild("Right Arm")
  583. end
  584. if motors[3] then
  585. motors[3].Part1 = character:findFirstChild("Head")
  586. end
  587. if welds[1] then
  588. welds[1]:remove()
  589. welds[1] = nil
  590. end
  591. if welds[2] then
  592. welds[2]:remove()
  593. welds[2] = nil
  594. end
  595. if welds[3] then
  596. welds[3]:remove()
  597. welds[3] = nil
  598. end
  599. weapon_parts[1].Parent = nil
  600. if weapon_model then
  601. weapon_model.Parent = nil
  602. end
  603. coroutine.resume(coroutine.create(function()
  604. local swm = weapon_model
  605. wait()
  606. swm.Parent = nil
  607. wait(0.1)
  608. swm.Parent = nil
  609. wait(0.5)
  610. swm.Parent = nil
  611. end))
  612. end
  613.  
  614. local anim_model = Instance.new("Model")
  615. anim_model.Name = "WeaponAnimation"
  616. weapon_model = anim_model
  617.  
  618. local cam_larm = Instance.new("Part")
  619. cam_larm.Parent = anim_model
  620. cam_larm.BrickColor = BrickColor.new("Really black")
  621. cam_larm.formFactor = "Custom"
  622. cam_larm.Size = Vector3.new(0.2, 0.2, 0.2)
  623. cam_larm.TopSurface = 0
  624. cam_larm.BottomSurface = 0
  625. cam_larm.Transparency = 0.4
  626. cam_larm.CanCollide = false
  627. local hmesh = Instance.new("BlockMesh", cam_larm)
  628. hmesh.Scale = Vector3.new(5, 10, 5)
  629.  
  630. local cam_rarm = cam_larm:clone()
  631. cam_rarm.Parent = anim_model
  632.  
  633. function StartAnimation()
  634. local check = {torso:findFirstChild("LeftWeld"), torso:findFirstChild("RightWeld"), torso:findFirstChild("HeadWeld")}
  635. if check[1] then check[1]:remove() end
  636. if check[2] then check[2]:remove() end
  637. if check[3] then check[3]:remove() end
  638. local check2 = {character:findFirstChild("WeaponObject"), camera:findFirstChild("WeaponAnimation")}
  639. if check2[1] then check2[1].Parent = nil end
  640. if check2[2] then check2[2].Parent = nil end
  641. if motors[1] then
  642. motors[1].Part1 = nil
  643. end
  644. if motors[2] then
  645. motors[2].Part1 = nil
  646. end
  647. if motors[3] then
  648. motors[3].Part1 = nil
  649. end
  650. welds = {Instance.new(conn_type), Instance.new(conn_type), Instance.new(conn_type)}
  651. welds[1].Part0 = torso
  652. welds[2].Part0 = torso
  653. welds[3].Part0 = torso
  654. welds[1].Part1 = character:findFirstChild("Left Arm")
  655. welds[2].Part1 = character:findFirstChild("Right Arm")
  656. welds[3].Part1 = character:findFirstChild("Head")
  657. welds[1].Name = "LeftWeld"
  658. welds[2].Name = "RightWeld"
  659. welds[2].Name = "HeadWeld"
  660. welds[1].C0 = CFrame.new(-1.5, 0, 0)
  661. welds[2].C0 = CFrame.new(1.5, 0, 0)
  662. welds[3].C0 = CFrame.new(0, 1.5, 0)
  663. welds[1].Parent = torso
  664. welds[2].Parent = torso
  665. welds[3].Parent = torso
  666.  
  667. weapon_parts[1].Parent = character
  668. local wep_weld = Instance.new(conn_type)
  669. wep_weld.Part0 = character:findFirstChild("Right Arm")
  670. wep_weld.Part1 = weapon_parts[1]
  671. wep_weld.C0 = CFrame.new()
  672. wep_weld.Parent = weapon_parts[1]
  673.  
  674. local weld1 = welds[1]
  675. local weld2 = welds[2]
  676. local weld3 = welds[3]
  677.  
  678. local cam_welds = {Instance.new(conn_type), Instance.new(conn_type), Instance.new(conn_type)}
  679. cam_welds[1].Part0 = torso
  680. cam_welds[1].Part1 = cam_larm
  681. cam_welds[1].Parent = cam_larm
  682. cam_welds[2].Part0 = torso
  683. cam_welds[2].Part1 = cam_rarm
  684. cam_welds[2].Parent = cam_rarm
  685. cam_welds[3].Part0 = cam_rarm
  686. cam_welds[3].Part1 = weapon_parts[2]
  687. cam_welds[3].Parent = weapon_parts[2]
  688. weapon_parts[2].Parent = anim_model
  689.  
  690. local move_anim_speed = 3
  691. local last_p = Vector3.new()
  692. local move_amm = 0
  693. coroutine.resume(coroutine.create(function()
  694. while weld1.Parent ~= nil do
  695. local delta = wait(1/25)
  696. local cur_p = torso.Position
  697. if (cur_p - last_p).magnitude >= 0.1 then
  698. move_amm = math.min(1, move_amm + delta * move_anim_speed)
  699. else
  700. move_amm = math.max(0, move_amm - delta * move_anim_speed)
  701. end
  702. last_p = cur_p
  703. end
  704. end))
  705.  
  706. local r_serv = game:GetService("RunService")
  707.  
  708. --EASTER EGG
  709. function easein(x)
  710. return math.sin(math.rad(x * 90))
  711. end
  712.  
  713. local a_horse = (character:findFirstChild("HorseHead") ~= nil)
  714. local horse_displace = {0, 0}
  715. local horse_cf = CFrame.Angles(0.0001, 0.0001, 0)
  716. if a_horse then
  717. coroutine.resume(coroutine.create(function()
  718. while weld1.Parent ~= nil do
  719. local rndwait = (math.random(100, 1000) / 1000) * 4
  720. wait(rndwait)
  721. local oldd = {horse_displace[1], horse_displace[2]}
  722. local disp2 = {math.random(-60, 60), math.random(0, 25)}
  723.  
  724. local ld = 0
  725. while ld ~= 1 do
  726. local st = tick()
  727. r_serv.RenderStepped:wait()
  728. ld = math.min(1, ld + ((tick() - st) * 4))
  729. local eff = easein(ld)
  730.  
  731. local x = oldd[1] - ((oldd[1] - disp2[1]) * eff)
  732. local y = oldd[2] - ((oldd[2] - disp2[2]) * eff)
  733. horse_displace = {x, y}
  734. horse_cf = CFrame.Angles(math.rad(y), math.rad(x) , 0)
  735. end
  736. end
  737. end))
  738. end
  739.  
  740. --EASTER EGG
  741.  
  742. local last_va = 0
  743. local last_va2 = 0
  744. local view_velocity = {0, 0}
  745.  
  746. coroutine.resume(coroutine.create(function()
  747. local last_time = tick()
  748. while weld1.Parent ~= nil do
  749. r_serv.RenderStepped:wait() ------------------------------------------------
  750. local delta = tick() - last_time
  751. last_time = tick()
  752.  
  753. local breathe_amp = 2
  754. local breathe_freq = 0.8
  755. local breathe = math.sin(math.rad(tick() * 90 * breathe_freq)) * breathe_amp
  756.  
  757. local shake_freq = 5
  758. local shake_amp = {0.05, 0.05}
  759. local arm_shake = CFrame.new(
  760. math.sin(math.rad(tick() * 90 * shake_freq)) * move_amm * shake_amp[1],
  761. 0,
  762. math.abs(math.sin(math.rad(tick() * 90 * shake_freq)) * move_amm * shake_amp[2]))
  763.  
  764.  
  765. --ANIMATION LOOP
  766. local p_distance = (head.Position - mouse.Hit.p).magnitude
  767. if p_distance == 0 then p_distance = 0.0001 end
  768. local p_height = mouse.Hit.p.y - head.Position.y
  769. local view_angle
  770. if p_height ~= 0 then
  771. view_angle = math.deg(math.asin(math.abs(p_height) / p_distance)) * (math.abs(p_height) / p_height)
  772. else
  773. view_angle = 0
  774. end
  775.  
  776. local cam_cf = camera.CoordinateFrame
  777. local looking_at = cam_cf * CFrame.new(0, 0, -100)
  778. local view_angle2 = math.deg(math.atan2(cam_cf.p.x - looking_at.p.x, cam_cf.p.z - looking_at.p.z)) + 180
  779.  
  780. local v_delta1, v_delta2
  781. local dir1 = 0
  782. local dir2 = 0
  783. v_delta1 = math.abs(view_angle - last_va)
  784. if v_delta1 ~= 0 then
  785. dir1 = (view_angle - last_va) / v_delta1
  786. end
  787. local va_check = {math.abs(view_angle2 - last_va2), 360 - math.abs(view_angle2 - last_va2)}
  788. if view_angle2 == last_va2 then
  789. dir2 = 0
  790. v_delta2 = 0
  791. elseif va_check[1] < va_check[2] then
  792. v_delta2 = va_check[1]
  793. dir2 = (view_angle2 - last_va2) / va_check[1]
  794. else
  795. v_delta2 = va_check[2]
  796. if last_va2 > view_angle2 then
  797. dir2 = 1
  798. else
  799. dir2 = -1
  800. end
  801. end
  802. last_va = view_angle
  803. last_va2 = view_angle2
  804.  
  805. view_velocity[1] = view_velocity[1] / (1 + (delta * anim_p.aim_retract))
  806. view_velocity[2] = view_velocity[2] / (1 + (delta * anim_p.aim_retract))
  807.  
  808. local calc1 = v_delta1 * dir1 * anim_p.aim_amp
  809. if calc1 ~= 0 then
  810. view_velocity[1] = view_velocity[1] + (math.min(anim_p.aim_max_change, math.abs(calc1)) * (calc1 / math.abs(calc1)))
  811. end
  812. local calc2 = v_delta2 * dir2 * anim_p.aim_amp
  813. if calc2 ~= 0 then
  814. view_velocity[2] = view_velocity[2] + (math.min(anim_p.aim_max_change, math.abs(calc2)) * (calc2 / math.abs(calc2)))
  815. end
  816.  
  817. if view_velocity[1] ~= 0 then
  818. view_velocity[1] = math.min(anim_p.aim_max_deg, math.abs(view_velocity[1])) * (math.abs(view_velocity[1]) / view_velocity[1])
  819. end
  820. if view_velocity[2] ~= 0 then
  821. view_velocity[2] = math.min(anim_p.aim_max_deg, math.abs(view_velocity[2])) * (math.abs(view_velocity[2]) / view_velocity[2])
  822. end
  823.  
  824. local anmtp = _G.MurderKnife_AnimType
  825. local anmst = _G.MurderKnife_AnimState
  826.  
  827. if anmst == nil then
  828. anmst = 0
  829. end
  830.  
  831. if anmtp ~= nil then
  832. if Animations[anmtp] == nil then
  833. anmtp = "Default"
  834. end
  835. else
  836. anmtp = "Default"
  837. end
  838. local curr_anim = PlayAnimation(anmtp, anmst) --left, right, weapon, wep trans
  839.  
  840. --curr_anim = {Animations.Default[1][3], Animations.Default[1][4], Animations.Default[1][5], 0}
  841.  
  842. 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)
  843. weld1.C1 = (chestCF * curr_anim[1] * CFrame.new(0, -0.5, 0)):inverse()
  844. weld2.C1 = (chestCF * curr_anim[2] * CFrame.new(0, -0.5, 0)):inverse()
  845. wep_weld.C1 = (curr_anim[3]):inverse()
  846. weapon_parts[1].Transparency = curr_anim[4]
  847. if anim_head then
  848. 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()
  849. else
  850. weld3.C1 = (CFrame.new(0, 0, 0)):inverse()
  851. end
  852.  
  853. if (head.Position - camera.CoordinateFrame.p).magnitude < 3 then
  854. if anim_model.Parent == nil then
  855. anim_model.Parent = camera
  856. end
  857. cam_welds[1].Parent = cam_larm
  858. cam_welds[2].Parent = cam_rarm
  859. cam_welds[3].Parent = weapon_parts[2]
  860. 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
  861. 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()
  862. 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()
  863. cam_welds[3].C1 = (curr_anim[3]):inverse()
  864. weapon_parts[2].Transparency = curr_anim[4]
  865. else
  866. if anim_model.Parent ~= nil then
  867. anim_model.Parent = nil
  868. end
  869. end
  870. --ANIMATION LOOP
  871. end
  872. end))
  873. end
  874.  
  875. local last_st = 0
  876. local eq = false
  877. tool.Selected:connect(function(mouse)
  878. if eq then return end
  879. eq = true
  880. wait()
  881. StartAnimation()
  882. end)
  883.  
  884. tool.Deselected:connect(function()
  885. eq = false
  886. EndAnimation()
  887. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement