local plr = game:GetService("Players").LocalPlayer local rs = game:GetService("RunService") local jb = 14 local function setup(char) local hum = char:WaitForChild("Humanoid") local root = char:WaitForChild("HumanoidRootPart") local joint = root:WaitForChild("RootJoint") local c0 = joint.C0 local on = false local function stop() if on then rs:UnbindFromRenderStep("backflip") on = false end if joint.Parent then joint.C0 = c0 end end hum.StateChanged:Connect(function(_, new) if new == Enum.HumanoidStateType.Landed or new == Enum.HumanoidStateType.Running then if on then stop() end return end if new ~= Enum.HumanoidStateType.Jumping then return end stop() on = true local md0 = hum.MoveDirection local cam = workspace.CurrentCamera.CFrame local look = Vector3.new(cam.LookVector.X, 0, cam.LookVector.Z).Unit local right = Vector3.new(cam.RightVector.X, 0, cam.RightVector.Z).Unit local dir if md0.Magnitude < 0.1 then dir = -Vector3.new(root.CFrame.LookVector.X, 0, root.CFrame.LookVector.Z).Unit else local f = md0:Dot(look) local r = md0:Dot(right) if math.abs(f) >= math.abs(r) then dir = f > 0 and look or -look else dir = r > 0 and right or -right end end local axis = root.CFrame:VectorToObjectSpace(Vector3.yAxis:Cross(dir)).Unit local g = workspace.Gravity local v = (hum.UseJumpPower and hum.JumpPower or math.sqrt(2 * g * hum.JumpHeight)) + jb local dur = math.max(2 * v / g * 0.95, 0.35) local t0 = os.clock() local boosted = false rs:BindToRenderStep("backflip", Enum.RenderPriority.Last.Value, function() local a = (os.clock() - t0) / dur if a >= 1 or hum.Health <= 0 or not root.Parent then stop() return end if not boosted then boosted = true root.AssemblyLinearVelocity += Vector3.new(0, jb, 0) end joint.C0 = CFrame.fromAxisAngle(axis, a * math.pi * 2) * c0 end) end) end if plr.Character then task.spawn(setup, plr.Character) end plr.CharacterAdded:Connect(setup)