SHOW:
|
|
- or go back to the newest paste.
1 | warn("Made FE by AydenGamin's FE compatibility script. Link: https://pastebin.com/zxnXeDZA") | |
2 | wait(1) | |
3 | warn("Bypassing / Injecting into FE...") | |
4 | wait(0.2) | |
5 | warn("Done! Running script in 2 seconds!") | |
6 | wait(2) | |
7 | if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end | |
8 | local Player,game,owner = owner,game | |
9 | local RealPlayer = Player | |
10 | do | |
11 | print("FE void script maker compatibility V2 by AydenGamin") | |
12 | local RealPlayer = RealPlayer | |
13 | script.Parent = RealPlayer.Character | |
14 | ||
15 | --Fake event to make stuff like Mouse.KeyDown work | |
16 | local Disconnect_Function = function(this) | |
17 | this[1].Functions[this[2]] = nil | |
18 | end | |
19 | local Disconnect_Metatable = {__index={disconnect=Disconnect_Function,Disconnect=Disconnect_Function}} | |
20 | local FakeEvent_Metatable = {__index={ | |
21 | Connect = function(this,f) | |
22 | local i = tostring(math.random(0,10000)) | |
23 | while this.Functions[i] do | |
24 | i = tostring(math.random(0,10000)) | |
25 | end | |
26 | this.Functions[i] = f | |
27 | return setmetatable({this,i},Disconnect_Metatable) | |
28 | end | |
29 | }} | |
30 | FakeEvent_Metatable.__index.connect = FakeEvent_Metatable.__index.Connect | |
31 | local function fakeEvent() | |
32 | return setmetatable({Functions={}},FakeEvent_Metatable) | |
33 | end | |
34 | ||
35 | --Creating fake input objects with fake variables | |
36 | local FakeMouse = {Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()} | |
37 | FakeMouse.keyUp = FakeMouse.KeyUp | |
38 | FakeMouse.keyDown = FakeMouse.KeyDown | |
39 | local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()} | |
40 | local CAS = {Actions={},BindAction=function(self,name,fun,touch,...) | |
41 | CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil | |
42 | end} | |
43 | --Merged 2 functions into one by checking amount of arguments | |
44 | CAS.UnbindAction = CAS.BindAction | |
45 | ||
46 | --This function will trigger the events that have been :Connect()'ed | |
47 | local function TriggerEvent(self,ev,...) | |
48 | for _,f in pairs(self[ev].Functions) do | |
49 | f(...) | |
50 | end | |
51 | end | |
52 | FakeMouse.TriggerEvent = TriggerEvent | |
53 | UIS.TriggerEvent = TriggerEvent | |
54 | ||
55 | --Client communication | |
56 | local Event = Instance.new("RemoteEvent") | |
57 | Event.Name = "UserInput_Event" | |
58 | Event.OnServerEvent:Connect(function(plr,io) | |
59 | if plr~=RealPlayer then return end | |
60 | FakeMouse.Target = io.Target | |
61 | FakeMouse.Hit = io.Hit | |
62 | if not io.isMouse then | |
63 | local b = io.UserInputState == Enum.UserInputState.Begin | |
64 | if io.UserInputType == Enum.UserInputType.MouseButton1 then | |
65 | return FakeMouse:TriggerEvent(b and "Button1Down" or "Button1Up") | |
66 | end | |
67 | if io.UserInputType == Enum.UserInputType.MouseButton2 then | |
68 | return FakeMouse:TriggerEvent(b and "Button2Down" or "Button2Up") | |
69 | end | |
70 | for _,t in pairs(CAS.Actions) do | |
71 | for _,k in pairs(t.Keys) do | |
72 | if k==io.KeyCode then | |
73 | t.Function(t.Name,io.UserInputState,io) | |
74 | end | |
75 | end | |
76 | end | |
77 | FakeMouse:TriggerEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower()) | |
78 | UIS:TriggerEvent(b and "InputBegan" or "InputEnded",io,false) | |
79 | end | |
80 | end) | |
81 | Event.Parent = NLS([==[local Event = script:WaitForChild("UserInput_Event") | |
82 | local Mouse = owner:GetMouse() | |
83 | local UIS = game:GetService("UserInputService") | |
84 | local input = function(io,RobloxHandled) | |
85 | if RobloxHandled then return end | |
86 | --Since InputObject is a client-side instance, we create and pass table instead | |
87 | Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target}) | |
88 | end | |
89 | UIS.InputBegan:Connect(input) | |
90 | UIS.InputEnded:Connect(input) | |
91 | local h,t | |
92 | --Give the server mouse data every second frame, but only if the values changed | |
93 | --If player is not moving their mouse, client won't fire events | |
94 | local HB = game:GetService("RunService").Heartbeat | |
95 | while true do | |
96 | if h~=Mouse.Hit or t~=Mouse.Target then | |
97 | h,t=Mouse.Hit,Mouse.Target | |
98 | Event:FireServer({isMouse=true,Target=t,Hit=h}) | |
99 | end | |
100 | --Wait 2 frames | |
101 | for i=1,2 do | |
102 | HB:Wait() | |
103 | end | |
104 | end]==],script) | |
105 | ||
106 | ----Sandboxed game object that allows the usage of client-side methods and services | |
107 | --Real game object | |
108 | local RealGame = game | |
109 | ||
110 | --Metatable for fake service | |
111 | local FakeService_Metatable = { | |
112 | __index = function(self,k) | |
113 | local s = rawget(self,"_RealService") | |
114 | if s then | |
115 | return typeof(s[k])=="function" | |
116 | and function(_,...)return s[k](s,...)end or s[k] | |
117 | end | |
118 | end, | |
119 | __newindex = function(self,k,v) | |
120 | local s = rawget(self,"_RealService") | |
121 | if s then s[k]=v end | |
122 | end | |
123 | } | |
124 | local function FakeService(t,RealService) | |
125 | t._RealService = typeof(RealService)=="string" and RealGame:GetService(RealService) or RealService | |
126 | return setmetatable(t,FakeService_Metatable) | |
127 | end | |
128 | ||
129 | --Fake game object | |
130 | local FakeGame = { | |
131 | GetService = function(self,s) | |
132 | return rawget(self,s) or RealGame:GetService(s) | |
133 | end, | |
134 | Players = FakeService({ | |
135 | LocalPlayer = FakeService({GetMouse=function(self)return FakeMouse end},Player) | |
136 | },"Players"), | |
137 | UserInputService = FakeService(UIS,"UserInputService"), | |
138 | ContextActionService = FakeService(CAS,"ContextActionService"), | |
139 | RunService = FakeService({ | |
140 | _btrs = {}, | |
141 | RenderStepped = RealGame:GetService("RunService").Heartbeat, | |
142 | BindToRenderStep = function(self,name,_,fun) | |
143 | self._btrs[name] = self.Heartbeat:Connect(fun) | |
144 | end, | |
145 | UnbindFromRenderStep = function(self,name) | |
146 | self._btrs[name]:Disconnect() | |
147 | end, | |
148 | },"RunService") | |
149 | } | |
150 | rawset(FakeGame.Players,"localPlayer",FakeGame.Players.LocalPlayer) | |
151 | FakeGame.service = FakeGame.GetService | |
152 | FakeService(FakeGame,game) | |
153 | --Changing owner to fake player object to support owner:GetMouse() | |
154 | game,owner = FakeGame,FakeGame.Players.LocalPlayer | |
155 | end | |
156 | ||
157 | game.Players.LocalPlayer.Character.Humanoid.MaxHealth = 999999e999999 | |
158 | local tool=Instance.new("HopperBin", game.Players.LocalPlayer.Backpack) | |
159 | tool.Name="SJ's Ultimate Ban Hammer" | |
160 | ||
161 | wait() | |
162 | script.Parent=tool | |
163 | ||
164 | --Murderer knife action script, original code from The Mad Murderer, by loleris. | |
165 | ||
166 | wait() | |
167 | local camera = game.Workspace.CurrentCamera | |
168 | local player = game.Players.LocalPlayer | |
169 | local character = player.Character | |
170 | local humanoid = character.Humanoid | |
171 | local head = character.Head | |
172 | local torso = character.Torso | |
173 | local pl_mouse = player:GetMouse() | |
174 | ||
175 | local rs = game:GetService("RunService") | |
176 | ||
177 | local stab_damage = 9999999e9999999 | |
178 | local walkspeeds = {80, 80} | |
179 | ||
180 | Settings = { | |
181 | Equip_time = 0.1, | |
182 | Idle_speed = 0.1, | |
183 | Attack_speed = 0.1, | |
184 | } | |
185 | ||
186 | local assetlink = "http://www.roblox.com/asset/?id=" | |
187 | local hit_sounds = {"501642310", "501642310", "501642310", "501642310"} | |
188 | local death_sounds = {"501642310", "501642310", "501642310"} | |
189 | function Clean(obj) | |
190 | spawn(function() | |
191 | wait(6) | |
192 | obj:remove() | |
193 | end) | |
194 | end | |
195 | ||
196 | function HIT_HANDLE(hit, dmg, pos) | |
197 | if hit == nil then return end | |
198 | local h = hit.Parent:findFirstChild("Humanoid") | |
199 | if h == nil then | |
200 | h = hit.Parent.Parent:findFirstChild("Humanoid") | |
201 | end | |
202 | if h == nil then return end | |
203 | if h.Health <= 0 then return end | |
204 | ||
205 | local head = h.Parent:findFirstChild("Head") | |
206 | if head == nil then return end | |
207 | ||
208 | local sound_part = Instance.new("Part") | |
209 | sound_part.formFactor = "Custom" | |
210 | sound_part.Size = Vector3.new(0.2, 0.2, 0.2) | |
211 | sound_part.Transparency = 1 | |
212 | sound_part.CanCollide = false | |
213 | sound_part.Anchored = true | |
214 | sound_part.CFrame = head.CFrame | |
215 | Clean(sound_part) | |
216 | sound_part.Parent = Workspace | |
217 | local s_hit = Instance.new("Sound") | |
218 | s_hit.Volume = 1 | |
219 | s_hit.SoundId = assetlink .. hit_sounds[math.random(1, #hit_sounds)] | |
220 | s_hit.Parent = sound_part | |
221 | local s_die = Instance.new("Sound") | |
222 | s_die.Volume = 1 | |
223 | s_die.SoundId = assetlink .. death_sounds[math.random(1, #death_sounds)] | |
224 | s_die.Parent = sound_part | |
225 | ||
226 | s_hit:play() | |
227 | ||
228 | local c_tag = Instance.new("ObjectValue") | |
229 | c_tag.Name = "creator" | |
230 | c_tag.Value = player | |
231 | c_tag.Parent = h | |
232 | h.Health=0 | |
233 | s_die:play() | |
234 | end | |
235 | ||
236 | function GENERATE_IGNORELIST() | |
237 | local result = {character, camera} | |
238 | local plr = game.Players:GetPlayers() | |
239 | for i = 1, #plr do | |
240 | if plr[i] ~= player then | |
241 | local char = plr[i].Character | |
242 | if char ~= nil then | |
243 | local ch = char:GetChildren() | |
244 | for i = 1, #ch do | |
245 | if ch[i]:IsA("Hat") or ch[i]:IsA("Tool") then | |
246 | result[#result + 1] = ch[i] | |
247 | end | |
248 | end | |
249 | end | |
250 | end | |
251 | end | |
252 | return result | |
253 | end | |
254 | ||
255 | function RayCast(pos1, pos2, dist, ign) | |
256 | local ray = Ray.new( | |
257 | pos1, | |
258 | (pos2 - pos1).unit * math.abs(dist) | |
259 | ) | |
260 | local hit, hpos = Workspace:FindPartOnRayWithIgnoreList(ray, ign, false) | |
261 | return hit, hpos | |
262 | end | |
263 | ||
264 | local larm = character:findFirstChild("Left Arm") | |
265 | local rarm = character:findFirstChild("Right Arm") | |
266 | function Slash(del) | |
267 | coroutine.resume(coroutine.create(function() | |
268 | local hits = {} | |
269 | ||
270 | local start = tick() | |
271 | local actv = true | |
272 | ||
273 | local function ishitted(obj) | |
274 | for i = 1, #hits do | |
275 | if obj:IsDescendantOf(hits[i]) then | |
276 | return true | |
277 | end | |
278 | end | |
279 | return false | |
280 | end | |
281 | ||
282 | local function hitp(hit) | |
283 | if ishitted(hit) then return end | |
284 | local h = hit.Parent:findFirstChild("Humanoid") | |
285 | if h == nil then | |
286 | h = hit.Parent.Parent:findFirstChild("Humanoid") | |
287 | end | |
288 | if h == nil then return end | |
289 | hits[#hits + 1] = h.Parent | |
290 | HIT_HANDLE(hit, stab_damage) | |
291 | end | |
292 | ||
293 | local con = { | |
294 | larm.Touched:connect(hitp), | |
295 | rarm.Touched:connect(hitp), | |
296 | } | |
297 | ||
298 | while tick() - start <= Settings.Attack_speed do wait() end | |
299 | actv = false | |
300 | con[1]:disconnect() | |
301 | con[2]:disconnect() | |
302 | end)) | |
303 | end | |
304 | ||
305 | local dg_sounds = { | |
306 | equip = { | |
307 | "465591978" | |
308 | }, | |
309 | hit = { | |
310 | "501642310", | |
311 | "501642310", | |
312 | "501642310", | |
313 | "501642310" | |
314 | }, | |
315 | swing = { | |
316 | "528494638", | |
317 | "528494638", | |
318 | "528494638", | |
319 | "528494638" | |
320 | } | |
321 | } | |
322 | ||
323 | local dg_soundobj = {} | |
324 | for k, v in pairs(dg_sounds) do | |
325 | dg_soundobj[k] = {} | |
326 | for i = 1, #v do | |
327 | local ns = Instance.new("Sound") | |
328 | ns.SoundId = assetlink .. v[i] | |
329 | ns.Volume = 1 | |
330 | dg_soundobj[k][#dg_soundobj[k] + 1] = ns | |
331 | end | |
332 | end | |
333 | ||
334 | function LoadSounds() | |
335 | for __, v in pairs(dg_soundobj) do | |
336 | for i = 1, #v do | |
337 | v[i].Parent = head | |
338 | end | |
339 | end | |
340 | end | |
341 | function RemoveSounds() | |
342 | for __, v in pairs(dg_soundobj) do | |
343 | for i = 1, #v do | |
344 | v[i].Parent = nil | |
345 | end | |
346 | end | |
347 | end | |
348 | function PlaySound(nm, dl) | |
349 | if dl == nil then | |
350 | dg_soundobj[nm][math.random(1, #dg_soundobj[nm])]:play() | |
351 | else | |
352 | coroutine.resume(coroutine.create(function() | |
353 | wait(dl) | |
354 | dg_soundobj[nm][math.random(1, #dg_soundobj[nm])]:play() | |
355 | end)) | |
356 | end | |
357 | end | |
358 | ||
359 | _G.MurderKnife_AnimType = "Default" | |
360 | _G.MurderKnife_AnimState = 0 | |
361 | ||
362 | function Animate(tp, st) | |
363 | _G.MurderKnife_AnimType = tp | |
364 | _G.MurderKnife_AnimState = st | |
365 | end | |
366 | ||
367 | tool.Selected:connect(function(mouse) --Default, Idle1, Idle2, Attack1, Attack2 | |
368 | humanoid.WalkSpeed = walkspeeds[2] | |
369 | mouse.Icon = assetlink .. "54019936" | |
370 | Animate("Equip", 0) | |
371 | LoadSounds() | |
372 | PlaySound("equip", 0.1) | |
373 | ||
374 | local anim_equip = 1 | |
375 | local last_action = tick() | |
376 | local idle_rand = math.random(4, 7) | |
377 | local idle_perform = 0 | |
378 | local idle_type = 1 | |
379 | ||
380 | local attack_perform = 0 | |
381 | local attack_type = 1 | |
382 | ||
383 | local running = true | |
384 | local last_c = tick() | |
385 | ||
386 | local click_start = tick() | |
387 | mouse.Button1Down:connect(function() | |
388 | if not running or anim_equip > 0 then return end | |
389 | if tick() - attack_perform <= Settings.Attack_speed then return end | |
390 | attack_perform = tick() | |
391 | last_action = tick() | |
392 | attack_type = math.random(1, 3) | |
393 | idle_perform = 0 | |
394 | PlaySound("swing", 0.1) | |
395 | Slash(0.1) | |
396 | end) | |
397 | ||
398 | local conn = rs.RenderStepped:connect(function() | |
399 | if not running then return end | |
400 | local delta = tick() - last_c | |
401 | last_c = tick() | |
402 | ||
403 | if anim_equip > 0 then | |
404 | anim_equip = math.max(0, anim_equip - (delta / Settings.Equip_time)) | |
405 | Animate("Equip", 1 - anim_equip) | |
406 | elseif tick() - attack_perform <= Settings.Attack_speed then | |
407 | Animate("Attack" .. attack_type, (tick() - attack_perform) / Settings.Attack_speed) | |
408 | idle_perform = 0 | |
409 | elseif tick() - idle_perform <= Settings.Idle_speed then | |
410 | Animate("Idle" .. idle_type, (tick() - idle_perform) / Settings.Idle_speed) | |
411 | else | |
412 | Animate("Default", 0) | |
413 | end | |
414 | ||
415 | if tick() - last_action >= idle_rand then | |
416 | idle_rand = math.random(12, 20) | |
417 | last_action = tick() | |
418 | idle_perform = tick() | |
419 | idle_type = math.random(1, 2) | |
420 | end | |
421 | ||
422 | end) | |
423 | tool.Deselected:connect(function() running = false conn:disconnect() end) | |
424 | end) | |
425 | tool.Deselected:connect(function() | |
426 | RemoveSounds() | |
427 | humanoid.WalkSpeed = walkspeeds[1] | |
428 | end) | |
429 | ||
430 | --Murderer knife animation module, original code from The Mad Murderer, by loleris. | |
431 | ||
432 | local mouse = pl_mouse | |
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=10604848", | |
440 | texture_id = "http://www.roblox.com/asset/?id=10605252", | |
441 | scale = Vector3.new(0.5, 0.5, 0.5), | |
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) | |
888 | ||
889 | local p = game.Players.LocalPlayer.Character | |
890 | local weld = Instance.new("Weld",p.Torso) | |
891 | weld.Part0 = p.Torso | |
892 | local weld2 = Instance.new("Weld",p.Torso) | |
893 | weld2.Part0 = p.Torso | |
894 | local Smoke = Instance.new("Part",p.Torso) | |
895 | Smoke.Anchored = true | |
896 | Smoke.CanCollide = false | |
897 | Smoke.Size = Vector3.new(1,1,1) | |
898 | Smoke.CustomPhysicalProperties = PhysicalProperties.new(0,0,0,0,0) | |
899 | weld2.Part1 = Smoke | |
900 | weld2.C1 = CFrame.new(0,-4,3.5)-- * CFrame.Angles(0,math.rad(180),0) | |
901 | Smoke.Anchored = false | |
902 | Smoke.Transparency = 1; | |
903 | ||
904 | local Particle = Instance.new("ParticleEmitter",Smoke) | |
905 | Particle.Rate = 3; | |
906 | Particle.Speed = NumberRange.new(30,30); | |
907 | Particle.VelocitySpread = 40; | |
908 | Particle.Texture = "rbxassetid://3412753" |