carlosname

Untitled

May 28th, 2020
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- // Animations // ---
  2. -- // By XqDIOpX
  3.  
  4. if game:GetService("RunService"):IsClient()then error("Please run as a server script. Use h/ instead of hl/.")end;print("FE Compatibility: by WaverlyCole");InternalData = {}
  5. do
  6.     script.Parent = owner.Character
  7.     local Event = Instance.new("RemoteEvent");Event.Name = "UserInput"
  8.     local function NewFakeEvent()
  9.         local Bind = Instance.new("BindableEvent")
  10.         local Fake;Fake = {Connections = {},
  11.         fakeEvent=true;
  12.         Connect=function(self,Func)
  13.             Bind.Event:connect(Func)
  14.             self.Connections[Bind] = true
  15.             return setmetatable({Connected = true},{
  16.             __index = function (self,Index)
  17.                 if Index:lower() == "disconnect" then
  18.                     return function() Fake.Connections[Bind] = false;self.Connected = false end
  19.                 end
  20.                 return Fake[Index]
  21.             end;
  22.             __tostring = function() return "Connection" end;
  23.         })
  24.         end}
  25.         Fake.connect = Fake.Connect;return Fake;
  26.     end
  27.     local Mouse = {Target=nil,Hit=CFrame.new(),KeyUp=NewFakeEvent(),KeyDown=NewFakeEvent(),Button1Up=NewFakeEvent(),Button1Down=NewFakeEvent()}
  28.     local UserInputService = {InputBegan=NewFakeEvent(),InputEnded=NewFakeEvent()}
  29.     local ContextActionService = {Actions={},BindAction = function(self,actionName,Func,touch,...)
  30.         self.Actions[actionName] = Func and {Name=actionName,Function=Func,Keys={...}} or nil
  31.     end};ContextActionService.UnBindAction = ContextActionService.BindAction
  32.     local function TriggerEvent(self,Event,...)
  33.         local Trigger = Mouse[Event]
  34.         if Trigger and Trigger.fakeEvent and Trigger.Connections then
  35.             for Connection,Active in pairs(Trigger.Connections) do if Active then Connection:Fire(...) end end
  36.         end
  37.     end
  38.     Mouse.TrigEvent = TriggerEvent;UserInputService.TrigEvent = TriggerEvent
  39.     Event.OnServerEvent:Connect(function(FiredBy,Input)
  40.         if FiredBy.Name ~= owner.Name then return end
  41.         if Input.MouseEvent then
  42.             Mouse.Target = Input.Target;Mouse.Hit = Input.Hit
  43.         else
  44.             local Begin = Input.UserInputState == Enum.UserInputState.Begin
  45.             if Input.UserInputType == Enum.UserInputType.MouseButton1 then return Mouse:TrigEvent(Begin and "Button1Down" or "Button1Up") end
  46.             for _,Action in pairs(ContextActionService.Actions) do
  47.                 for _,Key in pairs(Action.Keys) do if Key==Input.KeyCode then Action.Function(Action.Name,Input.UserInputState,Input) end end
  48.             end
  49.             Mouse:TrigEvent(Begin and "KeyDown" or "KeyUp",Input.KeyCode.Name:lower())
  50.             UserInputService:TrigEvent(Begin and "InputBegan" or "InputEnded",Input,false)
  51.         end
  52.     end)
  53.     InternalData["Mouse"] = Mouse;InternalData["ContextActionService"] = ContextActionService;InternalData["UserInputService"] = UserInputService
  54.     Event.Parent = NLS([[
  55.         local Player = owner;local Event = script:WaitForChild("UserInput");local UserInputService = game:GetService("UserInputService");local Mouse = Player:GetMouse()
  56.         local Input = function(Input,gameProcessedEvent)
  57.             if gameProcessedEvent then return end
  58.             Event:FireServer({KeyCode=Input.KeyCode,UserInputType=Input.UserInputType,UserInputState=Input.UserInputState})
  59.         end
  60.         UserInputService.InputBegan:Connect(Input);UserInputService.InputEnded:Connect(Input)
  61.         local Hit,Target
  62.         while wait(1/30) do
  63.             if Hit ~= Mouse.Hit or Target ~= Mouse.Target then
  64.                 Hit,Target = Mouse.Hit,Mouse.Target;Event:FireServer({["MouseEvent"]=true,["Target"]=Target,["Hit"]=Hit})
  65.             end
  66.         end
  67.     ]],owner.Character)
  68. end
  69. RealGame = game;game = setmetatable({},{
  70.     __index = function (self,Index)
  71.         local Sandbox = function (Thing)
  72.             if Thing:IsA("Player") then
  73.                 local RealPlayer = Thing
  74.                 return setmetatable({},{
  75.                     __index = function (self,Index)
  76.                         local Type = type(RealPlayer[Index])
  77.                         if Type == "function" then
  78.                             if Index:lower() == "getmouse" or Index:lower() == "mouse" then
  79.                                 return function (self)return InternalData["Mouse"] end
  80.                             end
  81.                             return function (self,...)return RealPlayer[Index](RealPlayer,...) end
  82.                         end
  83.                         return RealPlayer[Index]
  84.                     end;
  85.                     __tostring = function(self) return RealPlayer.Name end
  86.                 })
  87.             end
  88.         end
  89.         if RealGame[Index] then
  90.             local Type = type(RealGame[Index])
  91.             if Type == "function" then
  92.                 if Index:lower() == "getservice" or Index:lower() == "service" then
  93.                     return function (self,Service)
  94.                         local FakeServices = {
  95.                             ["players"] = function()
  96.                                 return setmetatable({},{
  97.                                     __index = function (self2,Index2)
  98.                                         local RealService = RealGame:GetService(Service)
  99.                                         local Type2 = type(Index2)
  100.                                         if Type2 == "function" then
  101.                                             return function (self,...) return RealService[Index2](RealService,...)end
  102.                                         else
  103.                                             if Index2:lower() == "localplayer" then return Sandbox(owner) end
  104.                                             return RealService[Index2]
  105.                                         end
  106.                                     end;
  107.                                     __tostring = function(self) return RealGame:GetService(Service).Name end
  108.                                 })
  109.                             end;
  110.                             ["contextactionservice"] = function() return InternalData["ContextActionService"] end;
  111.                             ["userinputservice"] = function() return InternalData["UserInputService"] end;
  112.                             ["runservice"] = function()
  113.                                 return setmetatable({},{
  114.                                     __index = function(self2,Index2)
  115.                                         local RealService = RealGame:GetService(Service)
  116.                                         local Type2 = type(Index2)
  117.                                         if Type2 == "function" then
  118.                                             return function (self,...) return RealService[Index2](RealService,...) end
  119.                                         else
  120.                                             local RunServices = {
  121.                                                 ["bindtorenderstep"] = function() return function (self,Name,Priority,Function) return RealGame:GetService("RunService").Stepped:Connect(Function) end end;
  122.                                                 ["renderstepped"] = function() return RealService["Stepped"] end
  123.                                             }
  124.                                             if RunServices[Index2:lower()] then return RunServices[Index2:lower()]() end
  125.                                             return RealService[Index2]
  126.                                         end
  127.                                     end
  128.                                 })
  129.                             end
  130.                         }
  131.                         if FakeServices[Service:lower()] then return FakeServices[Service:lower()]() end
  132.                         return RealGame:GetService(Service)
  133.                     end
  134.                 end
  135.                 return function (self,...) return RealGame[Index](RealGame,...) end
  136.             else
  137.                 if game:GetService(Index) then return game:GetService(Index) end
  138.                 return RealGame[Index]
  139.             end
  140.         end
  141.         return nil
  142.     end
  143. });Game = game;owner = game:GetService("Players").LocalPlayer;script = Instance.new("Script");print("Complete! Running...")
  144.  
  145. script.Name = 'Animation1'
  146. local plr = game:GetService('Players').LocalPlayer
  147. local char = plr.Character
  148. local hum = char:FindFirstChildOfClass('Humanoid')
  149. local ts = char:FindFirstChild('Torso')
  150. local hd = char:FindFirstChild('Head')
  151. local root = char:FindFirstChild('HumanoidRootPart')
  152. local ra = char:FindFirstChild('Right Arm')
  153. local la = char:FindFirstChild('Left Arm')
  154. local rl = char:FindFirstChild('Right Leg')
  155. local ll = char:FindFirstChild('Left Leg')
  156. local rs = ts:FindFirstChild('Right Shoulder')
  157. local ls = ts:FindFirstChild('Left Shoulder')
  158. local rh = ts:FindFirstChild('Right Hip')
  159. local lh = ts:FindFirstChild('Left Hip')
  160. local nk = ts:FindFirstChild('Neck')
  161. local rj = root:FindFirstChild('RootJoint')
  162. local bases = workspace:FindFirstChild('Baseplate') or workspace:FindFirstChild('Base')
  163. local hitsounds = {'264486467' ,'356551938'}
  164. local debris = game:GetService('Debris')
  165. local mouse = plr:GetMouse()
  166. local gun = Instance.new('Part', ra)
  167. local cf = {n = CFrame.new, a = CFrame.Angles, euler = CFrame.fromEulerAnglesXYZ, orn = CFrame.fromOrientation}
  168. local t = {i = table.insert, c = table.concat, r = table.remove}
  169. local c3 = {rgb = Color3.fromRGB, n = Color3.new, hsv = Color3.fromHSV}
  170. local str = {b = string.byte, s = string.sub, low = string.lower}
  171. local m = {c = math.cos, s = math.sin, r = math.rad, rand = math.random, pi = math.pi, huge = math.huge, tan = math.tan}
  172. local v = {t = Vector3.new, tw = Vector2.new}
  173. local cam = workspace.CurrentCamera
  174. local attack = false
  175. local onsit = false
  176. local onhit = false
  177. local cananim = true
  178. local anim = nil
  179. local effects = nil
  180. local regularspeed = 16
  181. local regularrun = regularspeed*3/2
  182. local sine = 0
  183. local change = 1
  184. local animspeed = 1
  185. local rsc0, lsc0, rhc0, lhc0, rjc0, nkc0 = rs.C0, ls.C0, rh.C0, lh.C0, rj.C0, nk.C0
  186. local holder = Instance.new('Part', gun)
  187. local pew = Instance.new('Sound', holder)
  188. local asd = Instance.new('ParticleEmitter')
  189. local gunmesh = Instance.new('SpecialMesh', gun)
  190.  
  191. gun.CanCollide = false
  192. gun.Size = v.t(0, 0, 0)
  193. gunmesh.MeshId = 'rbxassetid://443579590'
  194. gunmesh.TextureId = 'rbxassetid://443579679'
  195. gunmesh.Scale = v.t(0.05, 0.05, 0.05)
  196. holder.Transparency = 1
  197. pew.SoundId = 'rbxassetid://846233576'
  198. pew.Volume = 1
  199. pew.PlaybackSpeed = 0.9
  200. holder.Size = v.t(0.1, 0.1, 0.1)
  201. holder.CanCollide = false
  202. asd.Color = ColorSequence.new(Color3.new(1, 0, 0), Color3.new(.6, 0, 0))
  203. asd.LightEmission = .1
  204. asd.Size = NumberSequence.new(0.1)
  205. asd.Texture = 'rbxassetid://291880914'
  206. aaa = NumberSequence.new({NumberSequenceKeypoint.new(0, 0.3),NumberSequenceKeypoint.new(1, 7)})
  207. bbb = NumberSequence.new({NumberSequenceKeypoint.new(0, 10), NumberSequenceKeypoint.new(0.01, 0), NumberSequenceKeypoint.new(1, 1)})
  208. asd.Transparency = bbb
  209. asd.Size = aaa
  210. asd.ZOffset = .9
  211. asd.Acceleration = Vector3.new(0, -5, 0)
  212. asd.LockedToPart = false
  213. asd.EmissionDirection = "Back"
  214. asd.Lifetime = NumberRange.new(1, 2)
  215. asd.Rotation = NumberRange.new(-100, 100)
  216. asd.RotSpeed = NumberRange.new(-100, 100)
  217. asd.Speed = NumberRange.new(10)
  218. asd.Enabled = false
  219. asd.VelocitySpread = 100
  220.  
  221. function bloody(var, amount)
  222.     local particle = asd:Clone()
  223.     particle.Parent = var
  224.     particle:Emit(amount)
  225. end
  226.  
  227. if char:FindFirstChild('Effects') then
  228.     effects = char:FindFirstChild('Effects')
  229. else
  230.     effects = Instance.new('Folder', char)
  231.     effects.Name = 'Effects'
  232. end
  233.  
  234. hum.HealthChanged:connect(function()
  235.     hum.MaxHealth = hum.MaxHealth * hum.MaxHealth
  236.     hum.Health = hum.Health * hum.Health
  237. end)
  238.  
  239. char.ChildRemoved:connect(function(lol)
  240.     if effects ~= nil then
  241.         if lol == effects then
  242.             effects = Instance.new('Folder', char)
  243.             effects.Name = 'Effects'
  244.         end
  245.     end
  246. end)
  247.  
  248. ArtificialHB = Instance.new('BindableEvent', script)
  249. ArtificialHB.Name = 'Heartbeat'
  250. script:WaitForChild('Heartbeat')
  251.  
  252. frame = 1 / 60
  253. tf = 0
  254. allowframeloss = false
  255. tossremaincolorder = false
  256. lastframe = tick()
  257. script.Heartbeat:Fire()
  258.  
  259. game:GetService('RunService').Heartbeat:connect(function(s, p)
  260.     tf = tf + s
  261.     if tf >= frame then
  262.         if allowframeloss then
  263.             script.Heartbeat:Fire()
  264.             lastframe = tick()
  265.         else
  266.             for i = 1, math.floor(tf / frame) do
  267.                 script.Heartbeat:Fire()
  268.             end
  269.             lastframe = tick()
  270.         end
  271.         if tossremaincolorder then
  272.             tf = 0
  273.         else
  274.             tf = tf - frame * math.floor(tf / frame)
  275.         end
  276.     end
  277. end)
  278.  
  279. function swait(t)
  280.     if t == 0 or t == nil then
  281.         script.Heartbeat.Event:Wait()
  282.     else
  283.         for i = 0, t do
  284.             script.Heartbeat.Event:Wait()
  285.         end
  286.     end
  287. end
  288.  
  289. function sound(id, parent, vol, pitch, timeposition)
  290.     local s = Instance.new('Sound')
  291.     s.Parent = parent
  292.     s.SoundId = 'rbxassetid://'..id
  293.     s.Volume = vol
  294.     s.PlaybackSpeed = pitch
  295.     s.TimePosition = timeposition
  296.     s:Play()
  297.     debris:AddItem(s, pitch * 2)
  298. end
  299.  
  300. function weld(parent, p0, p1, c0, c1)
  301.     local gayweld = Instance.new('ManualWeld')
  302.     gayweld.Parent = parent
  303.     gayweld.Part0 = p0
  304.     gayweld.Part1 = p1
  305.     gayweld.C0 = c0
  306.     gayweld.C1 = c1
  307.     return gayweld
  308. end
  309.  
  310. function clerp(a, b, t)
  311.     return a:lerp(b, t)
  312. end
  313.  
  314. function raycast(pos, direction, range, ignoredecendants)
  315.     return workspace:FindPartOnRay(Ray.new(pos, direction.unit * range), ignoredecendants)
  316. end
  317.  
  318. function camshake(duration, intensity)
  319.     coroutine.wrap(function()
  320.         for shake = 1, duration*10 do
  321.             hum.CameraOffset = hum.CameraOffset:lerp(v.t(m.rand(-1, 1), m.rand(-1, 1), m.rand(-1, 1)), intensity)
  322.             swait()
  323.         end
  324.     hum.CameraOffset = v.t(0, 0, 0)
  325.     end)()
  326. end
  327.  
  328. function player(var)
  329.     if var.Parent then
  330.         if var.Parent:IsA('Model') and var.Parent:FindFirstChildOfClass('Humanoid') then
  331.             if var.Parent:FindFirstChild('Torso') or var:FindFirstChild('Head') or var.Parent:FindFirstChild('UpperTorso') then
  332.                 if var.Parent.Name ~= plr.Name then
  333.                     return var
  334.                 end
  335.             end
  336.         end
  337.     end
  338. end
  339.  
  340.  
  341. gun.Anchored = false
  342. weld(ra, ra, gun, cf.n(0.02, -1.735, -0.01) * cf.a(m.r(0), m.r(90), m.r(-90)), cf.n(0, 0, 0) * cf.a(0, 0, 0))
  343. weld(gun, gun, holder, cf.n(1.2, 0.75, 0), cf.n(0, 0, 0))
  344.  
  345.  
  346. while true do
  347.     sine = sine + change
  348.     local rootvel = (root.Velocity * v.t(1, 0, 1)).magnitude
  349.     local vertvel = (root.Velocity).y
  350.     local hitfloor = raycast(root.Position, (cf.n(root.Position, root.Position + v.t(0, -1, 0))).lookVector, 4 * 1, char)
  351.     pcall(function()
  352.         for i,v in pairs(char:GetChildren()) do
  353.             if v:IsA('LocalScript') and v.Name == 'Animate' then
  354.                 v.Parent = nil
  355.                 for i,v in pairs(hum:GetPlayingAnimationTracks()) do
  356.                     v:Stop()
  357.                 end
  358.                 coroutine.wrap(function()
  359.                     wait(3)
  360.                     for i,v in pairs(hum:GetChildren()) do
  361.                         if v:IsA('Animator') then
  362.                             v.Parent = nil
  363.                         end
  364.                     end
  365.                 end)()
  366.             end
  367.         end
  368.     end)
  369.     if cananim then
  370.         if vertvel > 1 and cananim == true and hitfloor == nil then
  371.             -- jump
  372.             change = 1
  373.             rj.C0 = clerp(rj.C0, rjc0 * cf.a(m.r(-10), m.r(0) + root.RotVelocity.Y/30, m.r(0)) * cf.n(0, 0, 0), 0.1)
  374.             nk.C0 = clerp(nk.C0, nkc0 * cf.a(m.r(-15), m.r(0), m.r(0)) * cf.n(0, 0, 0), .1)
  375.             rs.C0 = clerp(rs.C0, rsc0 * cf.a(m.r(-10), m.r(0) + ra.RotVelocity.Y/30, m.r(-0)) * cf.n(0, -0, 0), .15)
  376.             ls.C0 = clerp(ls.C0, lsc0 * cf.a(m.r(-10), m.r(0) + la.RotVelocity.Y/30, m.r(0)) * cf.n(0, -0, -0), .15)
  377.             rh.C0 = clerp(rh.C0, rhc0 * cf.a(m.r(0), m.r(0), m.r(-0)) * cf.n(0.55, 1, 0), 0.1)
  378.             lh.C0 = clerp(lh.C0, lhc0 * cf.a(m.r(0), m.r(0), m.r(0)) * cf.n(0, 0, 0), 0.1)
  379.         elseif vertvel < -1 and hitfloor == nil then
  380.             -- fall
  381.             change = 1
  382.             rj.C0 = clerp(rj.C0, rjc0 * cf.a(m.r(30), m.r(0) - root.RotVelocity.Y/30, m.r(0)) * cf.n(0, 0, 0), 0.050)
  383.             nk.C0 = clerp(nk.C0, nkc0 * cf.a(m.r(10), m.r(0), m.r(0)) * cf.n(0, 0, 0), .050)
  384.             rs.C0 = clerp(rs.C0, rsc0 * cf.a(m.r(-30), m.r(0) - ra.RotVelocity.Y/30, m.r(-0)) * cf.n(0, -0.2, 0), .050)
  385.             ls.C0 = clerp(ls.C0, lsc0 * cf.a(m.r(-30), m.r(0) - la.RotVelocity.Y/30, m.r(0)) * cf.n(0, -0.2, -0), .050)
  386.             rh.C0 = clerp(rh.C0, rhc0 * cf.a(m.r(0), m.r(0), m.r(-0)) * cf.n(0.55, 1, 0), 0.1)
  387.             lh.C0 = clerp(lh.C0, lhc0 * cf.a(m.r(0), m.r(0), m.r(0)) * cf.n(0, 0, 0), 0.1)
  388.         elseif rootvel < 2 and hitfloor ~= nil then
  389.             -- idle
  390.             change = 0.8
  391.             rj.C0 = clerp(rj.C0, rjc0 * cf.a(m.r(0 - 1 * m.c(sine/30)), m.r(0), m.r(0)) * cf.n(0, 0, 0 + 0.05 * m.c(sine/30)), animspeed/10)
  392.             nk.C0 = clerp(nk.C0, nkc0 * cf.a(m.r(5 - 2 * m.c(sine/30)), m.r(0), m.r(0)) * cf.n(0, 0, 0), animspeed/10)
  393.             rs.C0 = clerp(rs.C0, rsc0 * cf.a(m.r(-3 - 2 * m.c(sine/30)), m.r(0), m.r(0)) * cf.n(0, 0.050 * m.c(sine/25), 0), animspeed/10)
  394.             ls.C0 = clerp(ls.C0, lsc0 * cf.a(m.r(-3 - 2 * m.c(sine/30)), m.r(0), m.r(0)) * cf.n(0, 0.050 * m.c(sine/25), 0), animspeed/10)
  395.             rh.C0 = clerp(rh.C0, rhc0 * cf.a(m.r(-5), m.r(-10 + 3 * m.c(sine/30)), m.r(-1 * m.c(sine/30))) * cf.n(0, -0.05 * m.c(sine/30), 0), animspeed/10)
  396.             lh.C0 = clerp(lh.C0, lhc0 * cf.a(m.r(0), m.r(0), m.r(1 * m.c(sine/30))) * cf.n(0, -0.05 * m.c(sine/30), 0), animspeed/10)
  397.         elseif rootvel < 20 and hitfloor ~= nil then
  398.             -- walk
  399.             change = 0.9
  400.             rj.C0 = clerp(rj.C0, rjc0 * cf.a(m.r(6), m.r(0) + root.RotVelocity.Y/40, m.r(10 * m.s(sine/6))) * cf.n(0, 0, -0.010 + m.c(sine/3)), 0.050)
  401.             nk.C0 = clerp(nk.C0, nkc0 * cf.a(m.r(2 * m.s(sine/6)), m.r(-2 * m.s(sine/6)), m.r(-8 * m.s(sine/6)) + root.RotVelocity.Y/50) * cf.n(0, 0, 0), .050)
  402.             rs.C0 = clerp(rs.C0, rsc0 * cf.a(m.r(-5), m.r(5 * m.c(sine/6)), m.r(-60 * m.s(sine/6))) * cf.n(0, -0, 0), 0.050)
  403.             ls.C0 = clerp(ls.C0, lsc0 * cf.a(m.r(-5), m.r(5 * m.c(sine/6)), m.r(-60 * m.s(sine/6))) * cf.n(0, 0, 0.050), 0.050)
  404.             rh.C0 = clerp(rh.C0, rhc0 * cf.a(m.r(0) + rl.RotVelocity.Y / 40, m.r(0), m.r(90 * m.s(sine/6))) * cf.n(0.05 + m.c(sine/6), 0.1 + m.c(sine/6), 0), 0.080)
  405.             lh.C0 = clerp(lh.C0, lhc0 * cf.a(m.r(0) + -ll.RotVelocity.Y / 40, m.r(0), m.r(90 * m.s(sine/6))) * cf.n(-0.05 + m.c(sine/6), 0.1 - m.c(sine/6), 0), 0.080)
  406.         end
  407.     end
  408.     swait()
  409. end
Add Comment
Please, Sign In to add comment