local ContextActionService = game:GetService("ContextActionService") local RunService = game:GetService("RunService") local UserInputService = game:GetService("UserInputService") local Players = game:GetService("Players") local player = Players.LocalPlayer local IDLE_ANIM = 138298584365781 local WALK_ANIM = 132445272966466 local RUN_ANIM = 132445272966466 local PUNCH_ANIM = 100946798667454 local WALK_SPEED = 11 local SPRINT_SPEED = 29 local punchTrack local idleTrack local walkTrack local runTrack local debouncePunch = false local sprintEnabled = false local flingActive = false local flingCoroutine local function setSpeed(character, speed) local humanoid = character:FindFirstChildOfClass("Humanoid") if humanoid then humanoid.WalkSpeed = speed end end local function playIdle() if walkTrack and walkTrack.IsPlaying then walkTrack:Stop() end if runTrack and runTrack.IsPlaying then runTrack:Stop() end if idleTrack and not idleTrack.IsPlaying then idleTrack:Play() end end local function stopFling() flingActive = false flingCoroutine = nil end local function resetToInitialState() debouncePunch = false sprintEnabled = false stopFling() if idleTrack then idleTrack:Stop() end if walkTrack then walkTrack:Stop() end if runTrack then runTrack:Stop() end if punchTrack then punchTrack:Stop() end if player.Character then setSpeed(player.Character, WALK_SPEED) if idleTrack then idleTrack:Play() end end end local function startFling() local lp = Players.LocalPlayer local movel = 0.1 while flingActive do RunService.Heartbeat:Wait() local c = lp.Character local hrp = c and c:FindFirstChild("HumanoidRootPart") if hrp then local vel = hrp.Velocity hrp.Velocity = vel * 10000 + Vector3.new(0, 10000, 0) RunService.RenderStepped:Wait() hrp.Velocity = vel RunService.Stepped:Wait() hrp.Velocity = vel + Vector3.new(0, movel, 0) movel = -movel end end end local function loadAnimations(character) local humanoid = character:WaitForChild("Humanoid") -- Stop old animations and reset variables if idleTrack then idleTrack:Stop() end if walkTrack then walkTrack:Stop() end if runTrack then runTrack:Stop() end if punchTrack then punchTrack:Stop() end idleTrack, walkTrack, runTrack, punchTrack = nil, nil, nil, nil -- Load Idle local idleAnim = Instance.new("Animation") idleAnim.AnimationId = "rbxassetid://" .. IDLE_ANIM idleTrack = humanoid:LoadAnimation(idleAnim) idleTrack.Priority = Enum.AnimationPriority.Idle idleTrack.Looped = true idleTrack:Play() -- Load Walk local walkAnim = Instance.new("Animation") walkAnim.AnimationId = "rbxassetid://" .. WALK_ANIM walkTrack = humanoid:LoadAnimation(walkAnim) walkTrack.Priority = Enum.AnimationPriority.Movement walkTrack.Looped = true -- Load Run local runAnim = Instance.new("Animation") runAnim.AnimationId = "rbxassetid://" .. RUN_ANIM runTrack = humanoid:LoadAnimation(runAnim) runTrack.Priority = Enum.AnimationPriority.Movement runTrack.Looped = true humanoid.Running:Connect(function(speed) if speed > 2 then if sprintEnabled then if not runTrack.IsPlaying then walkTrack:Stop() runTrack:Play() end else if not walkTrack.IsPlaying then runTrack:Stop() walkTrack:Play() end end if idleTrack.IsPlaying then idleTrack:Stop() end else playIdle() end end) humanoid.Died:Connect(resetToInitialState) -- Load Punch local punchAnim = Instance.new("Animation") punchAnim.AnimationId = "rbxassetid://" .. PUNCH_ANIM punchTrack = humanoid:LoadAnimation(punchAnim) punchTrack.Priority = Enum.AnimationPriority.Action punchTrack.Looped = false punchTrack.Stopped:Connect(function() debouncePunch = false stopFling() playIdle() end) end player.CharacterAdded:Connect(function(character) sprintEnabled = false debouncePunch = false setSpeed(character, WALK_SPEED) loadAnimations(character) end) if player.Character then sprintEnabled = false debouncePunch = false setSpeed(player.Character, WALK_SPEED) loadAnimations(player.Character) end UserInputService.InputBegan:Connect(function(input, gameProcessed) if not gameProcessed and input.KeyCode == Enum.KeyCode.LeftShift then sprintEnabled = not sprintEnabled if player.Character then setSpeed(player.Character, sprintEnabled and SPRINT_SPEED or WALK_SPEED) end end end) local function punchAction(_, state, _) if state == Enum.UserInputState.Begin and punchTrack and not debouncePunch then debouncePunch = true flingActive = true if runTrack and runTrack.IsPlaying then runTrack:Stop() end if walkTrack and walkTrack.IsPlaying then walkTrack:Stop() end if idleTrack and idleTrack.IsPlaying then idleTrack:Stop() end punchTrack:Play() if not flingCoroutine or coroutine.status(flingCoroutine) == "dead" then flingCoroutine = coroutine.create(startFling) coroutine.resume(flingCoroutine) end end end ContextActionService:BindAction( "ForsakenPunch", punchAction, true, Enum.KeyCode.F ) ContextActionService:SetTitle("ForsakenPunch", "Punch") local function sprintToggleAction(_, state, _) if state == Enum.UserInputState.Begin then sprintEnabled = not sprintEnabled if player.Character then setSpeed(player.Character, sprintEnabled and SPRINT_SPEED or WALK_SPEED) end end end ContextActionService:BindAction( "ForsakenSprintToggle", sprintToggleAction, true, Enum.KeyCode.LeftShift ) ContextActionService:SetTitle("ForsakenSprintToggle", "Sprint")