Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- // Animations // ---
- -- // By XqDIOpX
- 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 = {}
- do
- script.Parent = owner.Character
- local Event = Instance.new("RemoteEvent");Event.Name = "UserInput"
- local function NewFakeEvent()
- local Bind = Instance.new("BindableEvent")
- local Fake;Fake = {Connections = {},
- fakeEvent=true;
- Connect=function(self,Func)
- Bind.Event:connect(Func)
- self.Connections[Bind] = true
- return setmetatable({Connected = true},{
- __index = function (self,Index)
- if Index:lower() == "disconnect" then
- return function() Fake.Connections[Bind] = false;self.Connected = false end
- end
- return Fake[Index]
- end;
- __tostring = function() return "Connection" end;
- })
- end}
- Fake.connect = Fake.Connect;return Fake;
- end
- local Mouse = {Target=nil,Hit=CFrame.new(),KeyUp=NewFakeEvent(),KeyDown=NewFakeEvent(),Button1Up=NewFakeEvent(),Button1Down=NewFakeEvent()}
- local UserInputService = {InputBegan=NewFakeEvent(),InputEnded=NewFakeEvent()}
- local ContextActionService = {Actions={},BindAction = function(self,actionName,Func,touch,...)
- self.Actions[actionName] = Func and {Name=actionName,Function=Func,Keys={...}} or nil
- end};ContextActionService.UnBindAction = ContextActionService.BindAction
- local function TriggerEvent(self,Event,...)
- local Trigger = Mouse[Event]
- if Trigger and Trigger.fakeEvent and Trigger.Connections then
- for Connection,Active in pairs(Trigger.Connections) do if Active then Connection:Fire(...) end end
- end
- end
- Mouse.TrigEvent = TriggerEvent;UserInputService.TrigEvent = TriggerEvent
- Event.OnServerEvent:Connect(function(FiredBy,Input)
- if FiredBy.Name ~= owner.Name then return end
- if Input.MouseEvent then
- Mouse.Target = Input.Target;Mouse.Hit = Input.Hit
- else
- local Begin = Input.UserInputState == Enum.UserInputState.Begin
- if Input.UserInputType == Enum.UserInputType.MouseButton1 then return Mouse:TrigEvent(Begin and "Button1Down" or "Button1Up") end
- for _,Action in pairs(ContextActionService.Actions) do
- for _,Key in pairs(Action.Keys) do if Key==Input.KeyCode then Action.Function(Action.Name,Input.UserInputState,Input) end end
- end
- Mouse:TrigEvent(Begin and "KeyDown" or "KeyUp",Input.KeyCode.Name:lower())
- UserInputService:TrigEvent(Begin and "InputBegan" or "InputEnded",Input,false)
- end
- end)
- InternalData["Mouse"] = Mouse;InternalData["ContextActionService"] = ContextActionService;InternalData["UserInputService"] = UserInputService
- Event.Parent = NLS([[
- local Player = owner;local Event = script:WaitForChild("UserInput");local UserInputService = game:GetService("UserInputService");local Mouse = Player:GetMouse()
- local Input = function(Input,gameProcessedEvent)
- if gameProcessedEvent then return end
- Event:FireServer({KeyCode=Input.KeyCode,UserInputType=Input.UserInputType,UserInputState=Input.UserInputState})
- end
- UserInputService.InputBegan:Connect(Input);UserInputService.InputEnded:Connect(Input)
- local Hit,Target
- while wait(1/30) do
- if Hit ~= Mouse.Hit or Target ~= Mouse.Target then
- Hit,Target = Mouse.Hit,Mouse.Target;Event:FireServer({["MouseEvent"]=true,["Target"]=Target,["Hit"]=Hit})
- end
- end
- ]],owner.Character)
- end
- RealGame = game;game = setmetatable({},{
- __index = function (self,Index)
- local Sandbox = function (Thing)
- if Thing:IsA("Player") then
- local RealPlayer = Thing
- return setmetatable({},{
- __index = function (self,Index)
- local Type = type(RealPlayer[Index])
- if Type == "function" then
- if Index:lower() == "getmouse" or Index:lower() == "mouse" then
- return function (self)return InternalData["Mouse"] end
- end
- return function (self,...)return RealPlayer[Index](RealPlayer,...) end
- end
- return RealPlayer[Index]
- end;
- __tostring = function(self) return RealPlayer.Name end
- })
- end
- end
- if RealGame[Index] then
- local Type = type(RealGame[Index])
- if Type == "function" then
- if Index:lower() == "getservice" or Index:lower() == "service" then
- return function (self,Service)
- local FakeServices = {
- ["players"] = function()
- return setmetatable({},{
- __index = function (self2,Index2)
- local RealService = RealGame:GetService(Service)
- local Type2 = type(Index2)
- if Type2 == "function" then
- return function (self,...) return RealService[Index2](RealService,...)end
- else
- if Index2:lower() == "localplayer" then return Sandbox(owner) end
- return RealService[Index2]
- end
- end;
- __tostring = function(self) return RealGame:GetService(Service).Name end
- })
- end;
- ["contextactionservice"] = function() return InternalData["ContextActionService"] end;
- ["userinputservice"] = function() return InternalData["UserInputService"] end;
- ["runservice"] = function()
- return setmetatable({},{
- __index = function(self2,Index2)
- local RealService = RealGame:GetService(Service)
- local Type2 = type(Index2)
- if Type2 == "function" then
- return function (self,...) return RealService[Index2](RealService,...) end
- else
- local RunServices = {
- ["bindtorenderstep"] = function() return function (self,Name,Priority,Function) return RealGame:GetService("RunService").Stepped:Connect(Function) end end;
- ["renderstepped"] = function() return RealService["Stepped"] end
- }
- if RunServices[Index2:lower()] then return RunServices[Index2:lower()]() end
- return RealService[Index2]
- end
- end
- })
- end
- }
- if FakeServices[Service:lower()] then return FakeServices[Service:lower()]() end
- return RealGame:GetService(Service)
- end
- end
- return function (self,...) return RealGame[Index](RealGame,...) end
- else
- if game:GetService(Index) then return game:GetService(Index) end
- return RealGame[Index]
- end
- end
- return nil
- end
- });Game = game;owner = game:GetService("Players").LocalPlayer;script = Instance.new("Script");print("Complete! Running...")
- script.Name = 'Animation1'
- local plr = game:GetService('Players').LocalPlayer
- local char = plr.Character
- local hum = char:FindFirstChildOfClass('Humanoid')
- local ts = char:FindFirstChild('Torso')
- local hd = char:FindFirstChild('Head')
- local root = char:FindFirstChild('HumanoidRootPart')
- local ra = char:FindFirstChild('Right Arm')
- local la = char:FindFirstChild('Left Arm')
- local rl = char:FindFirstChild('Right Leg')
- local ll = char:FindFirstChild('Left Leg')
- local rs = ts:FindFirstChild('Right Shoulder')
- local ls = ts:FindFirstChild('Left Shoulder')
- local rh = ts:FindFirstChild('Right Hip')
- local lh = ts:FindFirstChild('Left Hip')
- local nk = ts:FindFirstChild('Neck')
- local rj = root:FindFirstChild('RootJoint')
- local bases = workspace:FindFirstChild('Baseplate') or workspace:FindFirstChild('Base')
- local hitsounds = {'264486467' ,'356551938'}
- local debris = game:GetService('Debris')
- local mouse = plr:GetMouse()
- local gun = Instance.new('Part', ra)
- local cf = {n = CFrame.new, a = CFrame.Angles, euler = CFrame.fromEulerAnglesXYZ, orn = CFrame.fromOrientation}
- local t = {i = table.insert, c = table.concat, r = table.remove}
- local c3 = {rgb = Color3.fromRGB, n = Color3.new, hsv = Color3.fromHSV}
- local str = {b = string.byte, s = string.sub, low = string.lower}
- local m = {c = math.cos, s = math.sin, r = math.rad, rand = math.random, pi = math.pi, huge = math.huge, tan = math.tan}
- local v = {t = Vector3.new, tw = Vector2.new}
- local cam = workspace.CurrentCamera
- local attack = false
- local onsit = false
- local onhit = false
- local cananim = true
- local anim = nil
- local effects = nil
- local regularspeed = 16
- local regularrun = regularspeed*3/2
- local sine = 0
- local change = 1
- local animspeed = 1
- local rsc0, lsc0, rhc0, lhc0, rjc0, nkc0 = rs.C0, ls.C0, rh.C0, lh.C0, rj.C0, nk.C0
- local holder = Instance.new('Part', gun)
- local pew = Instance.new('Sound', holder)
- local asd = Instance.new('ParticleEmitter')
- local gunmesh = Instance.new('SpecialMesh', gun)
- gun.CanCollide = false
- gun.Size = v.t(0, 0, 0)
- gunmesh.MeshId = 'rbxassetid://443579590'
- gunmesh.TextureId = 'rbxassetid://443579679'
- gunmesh.Scale = v.t(0.05, 0.05, 0.05)
- holder.Transparency = 1
- pew.SoundId = 'rbxassetid://846233576'
- pew.Volume = 1
- pew.PlaybackSpeed = 0.9
- holder.Size = v.t(0.1, 0.1, 0.1)
- holder.CanCollide = false
- asd.Color = ColorSequence.new(Color3.new(1, 0, 0), Color3.new(.6, 0, 0))
- asd.LightEmission = .1
- asd.Size = NumberSequence.new(0.1)
- asd.Texture = 'rbxassetid://291880914'
- aaa = NumberSequence.new({NumberSequenceKeypoint.new(0, 0.3),NumberSequenceKeypoint.new(1, 7)})
- bbb = NumberSequence.new({NumberSequenceKeypoint.new(0, 10), NumberSequenceKeypoint.new(0.01, 0), NumberSequenceKeypoint.new(1, 1)})
- asd.Transparency = bbb
- asd.Size = aaa
- asd.ZOffset = .9
- asd.Acceleration = Vector3.new(0, -5, 0)
- asd.LockedToPart = false
- asd.EmissionDirection = "Back"
- asd.Lifetime = NumberRange.new(1, 2)
- asd.Rotation = NumberRange.new(-100, 100)
- asd.RotSpeed = NumberRange.new(-100, 100)
- asd.Speed = NumberRange.new(10)
- asd.Enabled = false
- asd.VelocitySpread = 100
- function bloody(var, amount)
- local particle = asd:Clone()
- particle.Parent = var
- particle:Emit(amount)
- end
- if char:FindFirstChild('Effects') then
- effects = char:FindFirstChild('Effects')
- else
- effects = Instance.new('Folder', char)
- effects.Name = 'Effects'
- end
- hum.HealthChanged:connect(function()
- hum.MaxHealth = hum.MaxHealth * hum.MaxHealth
- hum.Health = hum.Health * hum.Health
- end)
- char.ChildRemoved:connect(function(lol)
- if effects ~= nil then
- if lol == effects then
- effects = Instance.new('Folder', char)
- effects.Name = 'Effects'
- end
- end
- end)
- ArtificialHB = Instance.new('BindableEvent', script)
- ArtificialHB.Name = 'Heartbeat'
- script:WaitForChild('Heartbeat')
- frame = 1 / 60
- tf = 0
- allowframeloss = false
- tossremaincolorder = false
- lastframe = tick()
- script.Heartbeat:Fire()
- game:GetService('RunService').Heartbeat:connect(function(s, p)
- tf = tf + s
- if tf >= frame then
- if allowframeloss then
- script.Heartbeat:Fire()
- lastframe = tick()
- else
- for i = 1, math.floor(tf / frame) do
- script.Heartbeat:Fire()
- end
- lastframe = tick()
- end
- if tossremaincolorder then
- tf = 0
- else
- tf = tf - frame * math.floor(tf / frame)
- end
- end
- end)
- function swait(t)
- if t == 0 or t == nil then
- script.Heartbeat.Event:Wait()
- else
- for i = 0, t do
- script.Heartbeat.Event:Wait()
- end
- end
- end
- function sound(id, parent, vol, pitch, timeposition)
- local s = Instance.new('Sound')
- s.Parent = parent
- s.SoundId = 'rbxassetid://'..id
- s.Volume = vol
- s.PlaybackSpeed = pitch
- s.TimePosition = timeposition
- s:Play()
- debris:AddItem(s, pitch * 2)
- end
- function weld(parent, p0, p1, c0, c1)
- local gayweld = Instance.new('ManualWeld')
- gayweld.Parent = parent
- gayweld.Part0 = p0
- gayweld.Part1 = p1
- gayweld.C0 = c0
- gayweld.C1 = c1
- return gayweld
- end
- function clerp(a, b, t)
- return a:lerp(b, t)
- end
- function raycast(pos, direction, range, ignoredecendants)
- return workspace:FindPartOnRay(Ray.new(pos, direction.unit * range), ignoredecendants)
- end
- function camshake(duration, intensity)
- coroutine.wrap(function()
- for shake = 1, duration*10 do
- hum.CameraOffset = hum.CameraOffset:lerp(v.t(m.rand(-1, 1), m.rand(-1, 1), m.rand(-1, 1)), intensity)
- swait()
- end
- hum.CameraOffset = v.t(0, 0, 0)
- end)()
- end
- function player(var)
- if var.Parent then
- if var.Parent:IsA('Model') and var.Parent:FindFirstChildOfClass('Humanoid') then
- if var.Parent:FindFirstChild('Torso') or var:FindFirstChild('Head') or var.Parent:FindFirstChild('UpperTorso') then
- if var.Parent.Name ~= plr.Name then
- return var
- end
- end
- end
- end
- end
- gun.Anchored = false
- 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))
- weld(gun, gun, holder, cf.n(1.2, 0.75, 0), cf.n(0, 0, 0))
- while true do
- sine = sine + change
- local rootvel = (root.Velocity * v.t(1, 0, 1)).magnitude
- local vertvel = (root.Velocity).y
- local hitfloor = raycast(root.Position, (cf.n(root.Position, root.Position + v.t(0, -1, 0))).lookVector, 4 * 1, char)
- pcall(function()
- for i,v in pairs(char:GetChildren()) do
- if v:IsA('LocalScript') and v.Name == 'Animate' then
- v.Parent = nil
- for i,v in pairs(hum:GetPlayingAnimationTracks()) do
- v:Stop()
- end
- coroutine.wrap(function()
- wait(3)
- for i,v in pairs(hum:GetChildren()) do
- if v:IsA('Animator') then
- v.Parent = nil
- end
- end
- end)()
- end
- end
- end)
- if cananim then
- if vertvel > 1 and cananim == true and hitfloor == nil then
- -- jump
- change = 1
- 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)
- nk.C0 = clerp(nk.C0, nkc0 * cf.a(m.r(-15), m.r(0), m.r(0)) * cf.n(0, 0, 0), .1)
- 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)
- 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)
- 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)
- lh.C0 = clerp(lh.C0, lhc0 * cf.a(m.r(0), m.r(0), m.r(0)) * cf.n(0, 0, 0), 0.1)
- elseif vertvel < -1 and hitfloor == nil then
- -- fall
- change = 1
- 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)
- nk.C0 = clerp(nk.C0, nkc0 * cf.a(m.r(10), m.r(0), m.r(0)) * cf.n(0, 0, 0), .050)
- 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)
- 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)
- 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)
- lh.C0 = clerp(lh.C0, lhc0 * cf.a(m.r(0), m.r(0), m.r(0)) * cf.n(0, 0, 0), 0.1)
- elseif rootvel < 2 and hitfloor ~= nil then
- -- idle
- change = 0.8
- 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)
- 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)
- 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)
- 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)
- 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)
- 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)
- elseif rootvel < 20 and hitfloor ~= nil then
- -- walk
- change = 0.9
- 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)
- 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)
- 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)
- 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)
- 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)
- 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)
- end
- end
- swait()
- end
Add Comment
Please, Sign In to add comment