Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local RunService = game:GetService("RunService")
- local UserInputService = game:GetService("UserInputService")
- local Player = Players.LocalPlayer
- local Mouse = Player:GetMouse()
- local Camera = workspace.CurrentCamera
- local Character = Player.Character
- local Humanoid = Character.Humanoid
- local Head = Character.Head
- local Torso = Character.Torso
- local RootPart = Character.HumanoidRootPart
- local RightArm = Character["Right Arm"]
- local LeftArm = Character["Left Arm"]
- local RightLeg = Character["Right Leg"]
- local LeftLeg = Character["Left Leg"]
- local Functions = {}
- local KeyHolds = {}
- local Data, ReplicatedData = {}, {Animation = "Idle", JumpEnabled = true}
- setmetatable(Data, {
- __metatable = {},
- __index = function(Self, Index)
- return ReplicatedData[Index]
- end,
- __newindex = function(Self, Index, Value)
- if Data.Changed and type(Data.Changed) == "function" then
- Data.Changed(Index, Value)
- end
- ReplicatedData[Index] = Value
- end
- })
- function Functions.Weld(P0, P1, C0, C1)
- local Weld = Instance.new("Weld", P0)
- Weld.Part0, Weld.Part1, Weld.C0, Weld.C1 = P0, P1, C0, C1
- return Weld
- end
- local RootWeld = Functions.Weld(RootPart, Torso, CFrame.new(), CFrame.new())
- local RAWeld = Functions.Weld(Torso, RightArm, CFrame.new(1.5, 0.5, 0), CFrame.new(0, 0.5, 0))
- local LAWeld = Functions.Weld(Torso, LeftArm, CFrame.new(-1.5, 0.5, 0), CFrame.new(0, 0.5, 0))
- local RLWeld = Functions.Weld(Torso, RightLeg, CFrame.new(0.5, -1.5, 0), CFrame.new(0, 0.5, 0))
- local LLWeld = Functions.Weld(Torso, LeftLeg, CFrame.new(-0.5, -1.5, 0), CFrame.new(0, 0.5, 0))
- function Data.Changed(Index, Value)
- if Index == "Animation" then
- if Value == "Running" then
- Humanoid.WalkSpeed = 20
- else
- Humanoid.WalkSpeed = 12
- end
- end
- end
- Mouse.KeyDown:connect(function(K)
- local Key = K:lower()
- if Key:byte() == 48 then
- KeyHolds.SHIFT = true
- end
- end)
- Mouse.KeyUp:connect(function(K)
- local Key = K:lower()
- if Key:byte() == 48 then
- KeyHolds.SHIFT = false
- end
- end)
- Humanoid.Running:connect(function(Speed)
- if Speed > 0 then
- if KeyHolds.SHIFT then
- Data.Animation = "Running"
- elseif Data.Animation == "Idle" then
- Data.Animation = "Walking"
- end
- elseif Data.Animation == "Walking" or Data.Animation == "Running" then
- Data.Animation = "Idle"
- end
- end)
- Humanoid.Jumping:connect(function(Active)
- if Data.JumpEnabled then
- Data.JumpEnabled = false
- Humanoid.JumpPower = 40
- if Data.Animation == "Running" then
- Functions.Flip()
- elseif Active then
- Data.Animation = "Jumping"
- else
- Data.Animation = "Idle"
- end
- wait(0.25)
- Humanoid.JumpPower = 0
- wait(1)
- Humanoid.JumpPower = 40
- Data.JumpEnabled = true
- end
- end)
- Humanoid.FreeFalling:connect(function(Active)
- if Active then
- Data.Animation = "Falling"
- else
- Data.Animation = "Idle"
- end
- end)
- Humanoid.WalkSpeed, Humanoid.JumpPower = 12, 40
- function Functions.Animate(Angle)
- if Data.Animation == "Idle" then
- RootWeld.C0 = RootWeld.C0:Lerp(CFrame.new() * CFrame.Angles(math.sin(Angle / 2) * math.pi / 256, math.sin(Angle) * math.pi / 128, 0), 0.2)
- RAWeld.C0 = RAWeld.C0:Lerp(CFrame.new(1.5, 0.5, 0) * CFrame.Angles(math.sin(Angle) * math.pi / 32, 0, math.pi / 96), 0.2)
- LAWeld.C0 = LAWeld.C0:Lerp(CFrame.new(-1.5, 0.5, 0) * CFrame.Angles(math.sin(Angle) * -math.pi / 32, 0, -math.pi / 96), 0.2)
- RLWeld.C0 = RLWeld.C0:Lerp(CFrame.new(0.5, -1.5, 0) * CFrame.Angles(math.sin(Angle) * -math.pi / 48, 0, math.pi / 128), 0.2)
- LLWeld.C0 = LLWeld.C0:Lerp(CFrame.new(-0.5, -1.5, 0) * CFrame.Angles(math.sin(Angle) * math.pi / 48, 0, -math.pi / 128), 0.2)
- elseif Data.Animation == "Walking" then
- RootWeld.C0 = RootWeld.C0:Lerp(CFrame.new() * CFrame.Angles((math.sin(Angle * 2) - 1) * math.pi / 128, math.sin(Angle * 4) * math.pi / 48, 0), 0.2)
- RAWeld.C0 = RAWeld.C0:Lerp(CFrame.new(1.5, 0.5, 0) * CFrame.Angles(math.sin(Angle * 4) * math.pi / 10, 0, math.pi / 64), 0.2)
- LAWeld.C0 = LAWeld.C0:Lerp(CFrame.new(-1.5, 0.5, 0) * CFrame.Angles(math.sin(Angle * 4) * -math.pi / 10, 0, -math.pi / 64), 0.2)
- RLWeld.C0 = RLWeld.C0:Lerp(CFrame.new(0.5, -1.5, 0) * CFrame.Angles(math.sin(Angle * 4) * -math.pi / 12, 0, math.pi / 72), 0.2)
- LLWeld.C0 = LLWeld.C0:Lerp(CFrame.new(-0.5, -1.5, 0) * CFrame.Angles(math.sin(Angle * 4) * math.pi / 12, 0, -math.pi / 72), 0.2)
- elseif Data.Animation == "Running" then
- RootWeld.C0 = RootWeld.C0:Lerp(CFrame.new() * CFrame.Angles((math.sin(Angle * 2) - 1) * math.pi / 64, math.sin(Angle * 8) * math.pi / 32, 0), 0.2)
- RAWeld.C0 = RAWeld.C0:Lerp(CFrame.new(1.5, 0.5, 0) * CFrame.Angles(math.sin(Angle * 6) * math.pi / 6, 0, math.pi / 24), 0.2)
- LAWeld.C0 = LAWeld.C0:Lerp(CFrame.new(-1.5, 0.5, 0) * CFrame.Angles(math.sin(Angle * 6) * -math.pi / 6, 0, -math.pi / 24), 0.2)
- RLWeld.C0 = RLWeld.C0:Lerp(CFrame.new(0.5, -1.5, 0) * CFrame.Angles(math.sin(Angle * 6) * -math.pi / 8, 0, math.pi / 32), 0.2)
- LLWeld.C0 = LLWeld.C0:Lerp(CFrame.new(-0.5, -1.5, 0) * CFrame.Angles(math.sin(Angle * 6) * math.pi / 8, 0, -math.pi / 32), 0.2)
- elseif Data.Animation == "Jumping" then
- RootWeld.C0 = RootWeld.C0:Lerp(CFrame.new() * CFrame.Angles((math.sin(Angle * 4) + 2) * math.pi / 64, math.sin(Angle * 8) * math.pi / 64, 0), 0.2)
- RAWeld.C0 = RAWeld.C0:Lerp(CFrame.new(1.5, 0.5, 0) * CFrame.Angles(math.sin(Angle * 4) * math.pi / 16, 0, math.pi / 2 - (math.sin(Angle * 2) + 4) * math.pi / 12), 0.2)
- LAWeld.C0 = LAWeld.C0:Lerp(CFrame.new(-1.5, 0.5, 0) * CFrame.Angles(math.sin(Angle * 4) * -math.pi / 16, 0, -math.pi / 2 + (math.sin(Angle * 2) + 4) * math.pi / 12), 0.2)
- RLWeld.C0 = RLWeld.C0:Lerp(CFrame.new(0.5, -1.5, 0) * CFrame.Angles(math.sin(Angle * 4) * -math.pi / 24, 0, math.pi / 64), 0.2)
- LLWeld.C0 = LLWeld.C0:Lerp(CFrame.new(-0.5, -1.5, 0) * CFrame.Angles(math.sin(Angle * 4) * math.pi / 24, 0, -math.pi / 64), 0.2)
- elseif Data.Animation == "Falling" then
- RootWeld.C0 = RootWeld.C0:Lerp(CFrame.new() * CFrame.Angles((math.sin(Angle * 2) + 2) * math.pi / 64, math.sin(Angle * 4) * math.pi / 64, 0), 0.2)
- RAWeld.C0 = RAWeld.C0:Lerp(CFrame.new(1.5, 0.5, 0) * CFrame.Angles(math.sin(Angle * 4) * math.pi / 16, 0, math.pi / 4 - (math.sin(Angle * 2) + 2) * math.pi / 16), 0.2)
- LAWeld.C0 = LAWeld.C0:Lerp(CFrame.new(-1.5, 0.5, 0) * CFrame.Angles(math.sin(Angle * 4) * -math.pi / 16, 0, -math.pi / 4 + (math.sin(Angle * 2) + 2) * math.pi / 16), 0.2)
- RLWeld.C0 = RLWeld.C0:Lerp(CFrame.new(0.5, -1.5, 0) * CFrame.Angles(math.sin(Angle * 4) * -math.pi / 24, 0, math.pi / 32), 0.2)
- LLWeld.C0 = LLWeld.C0:Lerp(CFrame.new(-0.5, -1.5, 0) * CFrame.Angles(math.sin(Angle * 4) * math.pi / 24, 0, -math.pi / 32), 0.2)
- end
- end
- function Functions.Flip()
- Data.Animation = "Flipping"
- local Count = 0
- coroutine.wrap(function()
- RunService.Heartbeat:connect(function()
- if Count then
- if Count < 2 then
- Count = Count + 0.05
- local Angle = Count * math.pi / 4
- RootWeld.C0 = RootWeld.C0:Lerp(CFrame.new(0, math.sin(Angle * 2) ^ 2 * 4, 0) * CFrame.Angles(math.sin(Angle) * -math.pi * 2, math.sin(Angle) * math.pi / 24, 0), 0.6)
- RAWeld.C0 = RAWeld.C0:Lerp(CFrame.new(1.5, 0.5, 0) * CFrame.Angles(math.sin(Angle) * math.pi / 64, 0, math.pi / 2 - math.pi / 5), 0.6)
- LAWeld.C0 = LAWeld.C0:Lerp(CFrame.new(-1.5, 0.5, 0) * CFrame.Angles(math.sin(Angle) * -math.pi / 64, 0, -math.pi / 2 + math.pi / 5), 0.6)
- RLWeld.C0 = RLWeld.C0:Lerp(CFrame.new(0.5, -1.3, 0) * CFrame.Angles(math.pi / 3, 0, math.pi / 64), 0.6)
- LLWeld.C0 = LLWeld.C0:Lerp(CFrame.new(-0.5, -1.3, 0) * CFrame.Angles(math.pi / 3, 0, -math.pi / 64), 0.6)
- else
- Count = nil
- Data.Animation = "Running"
- end
- else
- coroutine.yield()
- end
- end)
- end)()
- end
- local Angle = 0
- RunService.Heartbeat:connect(function()
- Angle = Angle + math.pi / 128
- Functions.Animate(Angle)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement