Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --// New weapon framework
- --// Completely made by LordRevorius
- local Weapon_Name = ""
- local Players = game:GetService("Players")
- local RunService = game:GetService("RunService")
- local Heartbeat = RunService.Heartbeat
- local RenderStepped = RunService.RenderStepped
- local CF, CA, V3, pi, sin, cos, acos, rad, random = CFrame.new, CFrame.Angles, Vector3.new, math.pi, math.sin, math.cos, math.acos, math.rad, math.random
- local Player = Players.LocalPlayer
- local Camera = Workspace.CurrentCamera
- local Mouse = Player:GetMouse()
- repeat RenderStepped:wait() until Player.Character and Player.Character:IsDescendantOf(workspace)
- local Character = Player.Character
- local Character_Data = {
- HumanoidRootPart = Character:WaitForChild("HumanoidRootPart"),
- Humanoid = Character:WaitForChild("Humanoid"),
- Head = Character:WaitForChild("Head"),
- Torso = Character:WaitForChild("Torso"),
- Right_Arm = Character:WaitForChild("Right Arm"),
- Right_Leg = Character:WaitForChild("Right Leg"),
- Left_Arm = Character:WaitForChild("Left Arm"),
- Left_Leg = Character:WaitForChild("Left Leg")
- }
- --// Making sure the limbs won't move in another direction than we made them move.
- if Character:FindFirstChild("Animate") then
- Character.Animate.Disabled = true
- Character.Animate:Destroy()
- Character_Data.Humanoid:ClearAllChildren()
- end
- local Main = {
- Pose = "Idle",
- Position = 0,
- Jumping = false,
- Idle_Enabled = true,
- Moving = false,
- KeyDowns = {}
- }
- local Debounces = {}
- local function Interpolate(Start, End, Alpha)
- return Start:lerp(End, Alpha) --// New CFrame:lerp method, Extremely smooth.
- end
- local function Create(Class, Properties)
- local Object = Instance.new(Class)
- for Index, Value in pairs(Properties or {}) do
- if pcall(function() return Object[Index] end) then
- Object[Index] = Value
- end
- end
- return Object
- end
- --// Weld Creation
- local Default_CFrames = {
- Torso = {C0 = CF(0, -1, 0), C1 = CF(0, -1, 0)},
- Head = {C0 = CF(0, 1.5, 0), C1 = CF(0,0,0)},
- Right_Arm = {C0 = CF(1.5, .5, 0), C1 = CF(0, .5, 0)},
- Right_Leg = {C0 = CF(.5, -1, 0), C1 = CF(0, 1, 0)},
- Left_Arm = {C0 = CF(-1.5, .5, 0), C1 = CF(0, .5, 0)},
- Left_Leg = {C0 = CF(-.5, -1, 0), C1 = CF(0, 1, 0)},
- }
- local Torso = Create("Motor6D", {Parent = Character_Data.Torso, Part0 = Character_Data.HumanoidRootPart, Part1 = Character_Data.Torso, C0 = Default_CFrames.Torso.C0, C1 = Default_CFrames.Torso.C1})
- local Head = Create("Motor6D", {Parent = Character_Data.Head, Part0 = Character_Data.Torso, Part1 = Character_Data.Head, C0 = Default_CFrames.Head.C0, C1 = Default_CFrames.Head.C1})
- local Right_Arm = Create("Motor6D", {Parent = Character_Data.Right_Arm, Part0 = Character_Data.Torso, Part1 = Character_Data.Right_Arm, C0 = Default_CFrames.Right_Arm.C0, C1 = Default_CFrames.Left_Arm.C1})
- local Right_Leg = Create("Motor6D", {Parent = Character_Data.Right_Leg, Part0 = Character_Data.Torso, Part1 = Character_Data.Right_Leg, C0 = Default_CFrames.Right_Leg.C0, C1 = Default_CFrames.Right_Leg.C1})
- local Left_Arm = Create("Motor6D", {Parent = Character_Data.Left_Arm, Part0 = Character_Data.Torso, Part1 = Character_Data.Left_Arm, C0 = Default_CFrames.Left_Arm.C0, C1 = Default_CFrames.Left_Arm.C1})
- local Left_Leg = Create("Motor6D", {Parent = Character_Data.Left_Leg, Part0 = Character_Data.Torso, Part1 = Character_Data.Left_Leg, C0 = Default_CFrames.Left_Leg.C0, C1 = Default_CFrames.Left_Leg.C1})
- local Weapon_Model = Create("Model", {Parent = Character, Name = Weapon_Name})
- local function OnKeyDown(Key)
- Main.KeyDowns[Key] = true
- Main.KeyDowns[Key:byte()] = true
- if not Main.Moving then
- Main.Moving = true
- Main.Idle_Enabled = false
- if Key == "q" then
- local Original_WalkSpeed = Character_Data.Humanoid.WalkSpeed
- Character_Data.Humanoid.WalkSpeed = 0
- repeat
- Character_Data.Humanoid.CameraOffset = Interpolate(Character_Data.Humanoid.CameraOffset, V3(-Character_Data.Torso.Size.X/(4/3), 0, 0), .05)
- Torso.C1 = Interpolate(Torso.C1, Default_CFrames.Torso.C1 * CA(0, 0, rad(-35)), .1)
- Head.C0 = Interpolate(Head.C0, Default_CFrames.Head.C0 * CA(rad(-5 + sin(Main.Position/24)), 0, 0), .1)
- Right_Arm.C0 = Interpolate(Right_Arm.C0, Default_CFrames.Right_Arm.C0 * CA(0, 0, rad(5 + sin(Main.Position/24))), .1)
- Left_Arm.C0 = Interpolate(Left_Arm.C0, Default_CFrames.Left_Arm.C0 * CA(0, 0, rad(-5 - sin(Main.Position/24) - 25)), .1)
- Right_Leg.C0 = Interpolate(Right_Leg.C0, Default_CFrames.Right_Leg.C0 * CFrame.new(0, -Character_Data.Right_Leg.Size.Y/8, 0) * CA(0, 0, rad(5 + sin(Main.Position/24) - 25)), .1)
- Left_Leg.C0 = Interpolate(Left_Leg.C0, Default_CFrames.Left_Leg.C0 * CA(0, 0, rad(-5 - sin(Main.Position/24) - 25)), .1)
- RenderStepped:wait()
- until not Main.KeyDowns[Key]
- for _ = 1, 40 do
- Character_Data.Humanoid.CameraOffset = Interpolate(Character_Data.Humanoid.CameraOffset, V3(), .05)
- Torso.C1 = Interpolate(Torso.C1, Default_CFrames.Torso.C1, .1)
- Head.C0 = Interpolate(Head.C0, Default_CFrames.Head.C0 * CA(rad(-5 + sin(Main.Position/24)), 0, 0), .1)
- Right_Arm.C0 = Interpolate(Right_Arm.C0, Default_CFrames.Right_Arm.C0 * CA(0, 0, rad(5 + sin(Main.Position/24))), .1)
- Left_Arm.C0 = Interpolate(Left_Arm.C0, Default_CFrames.Left_Arm.C0 * CA(0, 0, rad(-5 - sin(Main.Position/24))), .1)
- Right_Leg.C0 = Interpolate(Right_Leg.C0, Default_CFrames.Right_Leg.C0 * CA(0, 0, rad(5 + sin(Main.Position/24))), .1)
- Left_Leg.C0 = Interpolate(Left_Leg.C0, Default_CFrames.Left_Leg.C0 * CA(0, 0, rad(-5 - sin(Main.Position/24))), .1)
- RenderStepped:wait()
- end
- Character_Data.Humanoid.WalkSpeed = Original_WalkSpeed
- elseif Key == "e" then
- local Original_WalkSpeed = Character_Data.Humanoid.WalkSpeed
- Character_Data.Humanoid.WalkSpeed = 0
- repeat
- Character_Data.Humanoid.CameraOffset = Interpolate(Character_Data.Humanoid.CameraOffset, V3(Character_Data.Torso.Size.X/(4/3), 0, 0), .05)
- Torso.C1 = Interpolate(Torso.C1, Default_CFrames.Torso.C1 * CA(0, 0, rad(35)), .1)
- Head.C0 = Interpolate(Head.C0, Default_CFrames.Head.C0 * CA(rad(-5 + sin(Main.Position/24)), 0, 0), .1)
- Right_Arm.C0 = Interpolate(Right_Arm.C0, Default_CFrames.Right_Arm.C0 * CA(0, 0, rad(5 + sin(Main.Position/24) + 25)), .1)
- Left_Arm.C0 = Interpolate(Left_Arm.C0, Default_CFrames.Left_Arm.C0 * CA(0, 0, rad(-5 - sin(Main.Position/24))), .1)
- Right_Leg.C0 = Interpolate(Right_Leg.C0, Default_CFrames.Right_Leg.C0 * CA(0, 0, rad(5 + sin(Main.Position/24) + 25)), .1)
- Left_Leg.C0 = Interpolate(Left_Leg.C0, Default_CFrames.Left_Leg.C0 * CFrame.new(0, -Character_Data.Left_Leg.Size.Y/8, 0) * CA(0, 0, rad(-5 - sin(Main.Position/24) + 25)), .1)
- RenderStepped:wait()
- until not Main.KeyDowns[Key]
- for _ = 1, 40 do
- Character_Data.Humanoid.CameraOffset = Interpolate(Character_Data.Humanoid.CameraOffset, V3(), .05)
- Torso.C1 = Interpolate(Torso.C1, Default_CFrames.Torso.C1, .1)
- Head.C0 = Interpolate(Head.C0, Default_CFrames.Head.C0 * CA(rad(-5 + sin(Main.Position/24)), 0, 0), .1)
- Right_Arm.C0 = Interpolate(Right_Arm.C0, Default_CFrames.Right_Arm.C0 * CA(0, 0, rad(5 + sin(Main.Position/24))), .1)
- Left_Arm.C0 = Interpolate(Left_Arm.C0, Default_CFrames.Left_Arm.C0 * CA(0, 0, rad(-5 - sin(Main.Position/24))), .1)
- Right_Leg.C0 = Interpolate(Right_Leg.C0, Default_CFrames.Right_Leg.C0 * CA(0, 0, rad(5 + sin(Main.Position/24))), .1)
- Left_Leg.C0 = Interpolate(Left_Leg.C0, Default_CFrames.Left_Leg.C0 * CA(0, 0, rad(-5 - sin(Main.Position/24))), .1)
- RenderStepped:wait()
- end
- Character_Data.Humanoid.WalkSpeed = Original_WalkSpeed
- end
- Main.Moving = false
- Main.Idle_Enabled = true
- end
- end
- local function OnKeyUp(Key)
- Main.KeyDowns[Key] = false
- Main.KeyDowns[Key:byte()] = false
- end
- local function CheckJump(Value)
- Main.Jumping = Value
- end
- --// Weapon Creation
- --// Parts
- --// Meshes
- --// Welds
- local function Main_RenderStepped() --// Main animation loop.
- local Movement = 1
- if Main.Idle_Enabled then
- if Main.Jumping then
- Main.Pose = "Jumping"
- elseif (Character_Data.Torso.Velocity * V3(1, 0, 1)).magnitude < 2 then
- Main.Pose = "Idle"
- elseif (Character_Data.Torso.Velocity * V3(1, 0, 1)).magnitude < 24 then
- Main.Pose = "Walking"
- elseif (Character_Data.Torso.Velocity * V3(1, 0, 1)).magnitude >= 24 then
- Main.Pose = "Running"
- end
- if Main.Pose == "Idle" then
- Head.C0 = Interpolate(Head.C0, Default_CFrames.Head.C0 * CA(rad(-5 + sin(Main.Position/24)), 0, 0), .2)
- Torso.C0 = Interpolate(Torso.C0, Default_CFrames.Torso.C0, .2)
- Right_Arm.C0 = Interpolate(Right_Arm.C0, Default_CFrames.Right_Arm.C0 * CA(0, 0, rad(5 + sin(Main.Position/24))), .2)
- Left_Arm.C0 = Interpolate(Left_Arm.C0, Default_CFrames.Left_Arm.C0 * CA(0, 0, rad(-5 - sin(Main.Position/24))), .2)
- Right_Leg.C0 = Interpolate(Right_Leg.C0, Default_CFrames.Right_Leg.C0 * CA(0, 0, rad(5 + sin(Main.Position/24))), .2)
- Left_Leg.C0 = Interpolate(Left_Leg.C0, Default_CFrames.Left_Leg.C0 * CA(0, 0, rad(-5 - sin(Main.Position/24))), .2)
- elseif Main.Pose == "Jumping" then
- Movement = 2
- Head.C0 = Interpolate(Head.C0, Default_CFrames.Head.C0 * CA(rad(-5 + sin(Main.Position/24)), 0, 0), .2)
- Torso.C0 = Interpolate(Torso.C0, Default_CFrames.Torso.C0, .2)
- Right_Arm.C0 = Interpolate(Right_Arm.C0, Default_CFrames.Right_Arm.C0 * CA(rad(150 + sin(Main.Position/6)*5), 0, rad(5 + sin(Main.Position/24))), .2)
- Left_Arm.C0 = Interpolate(Left_Arm.C0, Default_CFrames.Left_Arm.C0 * CA(rad(150 + sin(Main.Position/6)*5), 0, rad(-5 - sin(Main.Position/24))), .2)
- Right_Leg.C0 = Interpolate(Right_Leg.C0, Default_CFrames.Right_Leg.C0 * CA(sin(Main.Position/24)/8, 0, rad(5) + cos(Main.Position/24)/24), .2)
- Left_Leg.C0 = Interpolate(Left_Leg.C0, Default_CFrames.Left_Leg.C0 * CA(sin(-Main.Position/24)/8, 0, rad(-5) - cos(Main.Position/24)/24), .2)
- elseif Main.Pose == "Walking" then
- Head.C0 = Interpolate(Head.C0, Default_CFrames.Head.C0 * CA(rad(-5 + sin(Main.Position/8)), 0, 0), .2)
- Torso.C0 = Interpolate(Torso.C0, Default_CFrames.Torso.C0, .2)
- Right_Arm.C0 = Interpolate(Right_Arm.C0, Default_CFrames.Right_Arm.C0 * CA(sin(-Main.Position/8)/2, 0, rad(5 + sin(Main.Position/24))), .2)
- Left_Arm.C0 = Interpolate(Left_Arm.C0, Default_CFrames.Left_Arm.C0 * CA(sin(Main.Position/8)/2, 0, rad(-5 - sin(Main.Position/24))), .2)
- Right_Leg.C0 = Interpolate(Right_Leg.C0, Default_CFrames.Right_Leg.C0 * CA(sin(Main.Position/8)/1.5, 0, 0), .2)
- Left_Leg.C0 = Interpolate(Left_Leg.C0, Default_CFrames.Left_Leg.C0 * CA(sin(-Main.Position/8)/1.5, 0, 0), .2)
- elseif Main.Pose == "Running" then
- Head.C0 = Interpolate(Head.C0, Default_CFrames.Head.C0 * CA(rad(-5 + sin(Main.Position/5)), 0, 0), .2)
- Torso.C0 = Interpolate(Torso.C0, Default_CFrames.Torso.C0, .2)
- Right_Arm.C0 = Interpolate(Right_Arm.C0, Default_CFrames.Right_Arm.C0 * CA(sin(-Main.Position/5)/1.5, 0, rad(5 + sin(Main.Position/24))), .2)
- Left_Arm.C0 = Interpolate(Left_Arm.C0, Default_CFrames.Left_Arm.C0 * CA(sin(Main.Position/5)/1.5, 0, rad(-5 - sin(Main.Position/24))), .2)
- Right_Leg.C0 = Interpolate(Right_Leg.C0, CF(.5, -1, 0) * CA(sin(Main.Position/5)/1.25, 0, 0), .2)
- Left_Leg.C0 = Interpolate(Left_Leg.C0, Default_CFrames.Left_Leg.C0 * CA(sin(-Main.Position/5)/1.25, 0, 0), .2)
- end
- end
- Main.Position = Main.Position + Movement
- end
- Mouse.KeyDown:connect(OnKeyDown)
- Mouse.KeyUp:connect(OnKeyUp)
- RenderStepped:connect(Main_RenderStepped)
- Character_Data.Humanoid.FreeFalling:connect(CheckJump)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement