Advertisement
bmrx13

hammer

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