Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- half made by gpt cuz of errors xd
- -- sprint
- workspace.Camera.FieldOfView = 85
- local Player = game:GetService("Players").LocalPlayer
- local UserInputService = game:GetService("UserInputService")
- local RunService = game:GetService("RunService")
- -- configuration
- local SPRINT_KEY = Enum.KeyCode.LeftShift
- local SPRINT_SPEED_MULTIPLIER = 1.3
- local MAX_STAMINA = 100
- local STAMINA_DEPLETION_RATE = 10 -- per sec
- local STAMINA_REGENERATION_RATE = 20
- local COOLDOWN_DURATION = 3
- -- variables
- local stamina = MAX_STAMINA
- local isSprinting = false
- local isCooldown = false
- local lastUpdate = os.clock()
- local humanoid
- local baseWalkSpeed
- local AnimRuninTrack
- local connections = {}
- -- GUI
- local gui = Instance.new("ScreenGui")
- gui.Name = "StaminaGUI"
- gui.Parent = Player:WaitForChild("PlayerGui")
- local frame = Instance.new("Frame")
- frame.Size = UDim2.new(0.2, 0, 0.03, 0)
- frame.Position = UDim2.new(0.1, 0, 0.9, 0)
- frame.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
- frame.BorderSizePixel = 2
- frame.BorderColor3 = Color3.fromRGB(20, 20, 20)
- frame.Parent = gui
- local bar = Instance.new("Frame")
- bar.Size = UDim2.new(1, 0, 1, 0)
- bar.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
- bar.BorderSizePixel = 0
- bar.Parent = frame
- local textLabel = Instance.new("TextLabel")
- textLabel.Size = UDim2.new(1, 0, 1, 0)
- textLabel.BackgroundTransparency = 1
- textLabel.Text = "Stamina: 100%"
- textLabel.TextColor3 = Color3.fromRGB(0, 0, 0)
- textLabel.Font = Enum.Font.SourceSansBold
- textLabel.TextSize = 14
- textLabel.Parent = frame
- -- Cleanup function
- local function cleanup()
- -- Disconnect all connections
- for _, connection in pairs(connections) do
- connection:Disconnect()
- end
- connections = {}
- -- Stop and clean up animation
- if AnimRuninTrack then
- AnimRuninTrack:Stop()
- AnimRuninTrack:Destroy()
- AnimRuninTrack = nil
- end
- -- Reset variables
- isSprinting = false
- humanoid = nil
- end
- --update GUI
- local function updateGUI()
- local percentage = math.floor((stamina / MAX_STAMINA) * 100)
- bar.Size = UDim2.new(stamina / MAX_STAMINA, 0, 1, 0)
- textLabel.Text = "Stamina: " .. percentage .. "%"
- end
- -- Initialize character
- local function setupCharacter(character)
- -- Clean up previous character
- cleanup()
- humanoid = character:WaitForChild("Humanoid")
- baseWalkSpeed = humanoid.WalkSpeed
- -- Create animation track
- local AnimRunin = Instance.new("Animation")
- AnimRunin.AnimationId = "rbxassetid://204328711"
- AnimRuninTrack = humanoid:LoadAnimation(AnimRunin)
- -- Reset state
- isSprinting = false
- stamina = MAX_STAMINA
- isCooldown = false
- updateGUI()
- -- Handle death
- table.insert(connections, humanoid.Died:Connect(function()
- cleanup() -- This will completely disable the script
- end))
- -- Clean up when character is removed
- table.insert(connections, character:GetPropertyChangedSignal("Parent"):Connect(function()
- if not character.Parent then
- cleanup()
- end
- end))
- end
- -- Set up connections
- table.insert(connections, Player.CharacterAdded:Connect(setupCharacter))
- if Player.Character then
- setupCharacter(Player.Character)
- end
- table.insert(connections, UserInputService.InputBegan:Connect(function(input, gameProcessed)
- if gameProcessed then return end
- if input.KeyCode == SPRINT_KEY and humanoid and not isCooldown and stamina > 10 then
- if humanoid:GetState() ~= Enum.HumanoidStateType.Climbing then
- if AnimRuninTrack then
- AnimRuninTrack:Play(0.1, 0.1, 0)
- AnimRuninTrack:AdjustSpeed(2.5)
- end
- isSprinting = true
- humanoid.WalkSpeed = baseWalkSpeed * SPRINT_SPEED_MULTIPLIER
- end
- end
- end))
- table.insert(connections, UserInputService.InputEnded:Connect(function(input, gameProcessed)
- if input.KeyCode == SPRINT_KEY and isSprinting then
- if humanoid then
- if AnimRuninTrack then
- AnimRuninTrack:Stop()
- end
- humanoid.WalkSpeed = baseWalkSpeed
- end
- isSprinting = false
- end
- end))
- table.insert(connections, RunService.Heartbeat:Connect(function()
- local now = os.clock()
- local deltaTime = now - lastUpdate
- lastUpdate = now
- if not humanoid then
- isSprinting = false
- return
- end
- if isSprinting then
- stamina = math.max(0, stamina - STAMINA_DEPLETION_RATE * deltaTime)
- if stamina <= 0 then
- isSprinting = false
- isCooldown = true
- humanoid.WalkSpeed = baseWalkSpeed
- if AnimRuninTrack then
- AnimRuninTrack:Stop()
- end
- task.delay(COOLDOWN_DURATION, function()
- isCooldown = false
- end)
- end
- else
- if not isCooldown then
- stamina = math.min(MAX_STAMINA, stamina + STAMINA_REGENERATION_RATE * deltaTime)
- end
- end
- updateGUI()
- end))
- -- Charge Ability
- local UserInputService = game:GetService("UserInputService")
- local Players = game:GetService("Players")
- local player = Players.LocalPlayer
- local chargeConnection
- local ChargeAnimTrack
- local isChargeAnimPlaying = false
- local scriptActive = true
- local function setupCharacter(character)
- if not scriptActive then return end
- -- delete anims
- if chargeConnection then
- chargeConnection:Disconnect()
- chargeConnection = nil
- end
- local humanoid = character:WaitForChild("Humanoid")
- local ChargeAnim = Instance.new("Animation")
- ChargeAnim.AnimationId = "rbxassetid://218504594"
- ChargeAnimTrack = humanoid:LoadAnimation(ChargeAnim)
- chargeConnection = UserInputService.InputBegan:Connect(function(input, gameProcessed)
- if not scriptActive then return end
- if not gameProcessed and input.KeyCode == Enum.KeyCode.E then
- isChargeAnimPlaying = not isChargeAnimPlaying
- if isChargeAnimPlaying then
- for _, track in pairs(humanoid:GetPlayingAnimationTracks()) do
- track:Stop()
- end
- ChargeAnimTrack:Play()
- ChargeAnimTrack.TimePosition = 0.25
- ChargeAnimTrack:AdjustSpeed(0)
- humanoid.WalkSpeed = 22
- workspace.Camera.FieldOfView = 65
- else
- ChargeAnimTrack:AdjustSpeed(1)
- task.wait(0.1)
- humanoid.WalkSpeed = 16
- ChargeAnimTrack:Stop()
- workspace.Camera.FieldOfView = 85
- end
- end
- end)
- end
- local punchConnection
- local PunchAnimTrack
- local isPunchAnimPlaying = false
- local function setupPunchAbility(character)
- if not scriptActive then return end
- if punchConnection then
- punchConnection:Disconnect()
- punchConnection = nil
- end
- local humanoid = character:WaitForChild("Humanoid")
- local rootPart = character:WaitForChild("HumanoidRootPart")
- local PunchAnim = Instance.new("Animation")
- PunchAnim.AnimationId = "rbxassetid://204062532"
- PunchAnimTrack = humanoid:LoadAnimation(PunchAnim)
- punchConnection = UserInputService.InputBegan:Connect(function(input, gameProcessed)
- if not scriptActive then return end
- if not gameProcessed and input.KeyCode == Enum.KeyCode.R and not isPunchAnimPlaying then
- isPunchAnimPlaying = true
- for _, track in pairs(humanoid:GetPlayingAnimationTracks()) do
- track:Stop()
- end
- PunchAnimTrack:Play()
- PunchAnimTrack:AdjustSpeed(0.25)
- humanoid.WalkSpeed = 4
- wait(0.6)
- -- move forward thing
- local direction = rootPart.CFrame.LookVector
- local punchForce = 100
- rootPart.AssemblyLinearVelocity = direction * punchForce
- PunchAnimTrack:AdjustSpeed(2)
- humanoid.WalkSpeed = 16
- PunchAnimTrack.Stopped:Wait()
- isPunchAnimPlaying = false
- end
- end)
- end
- -- Block Ability
- local BlockConnection
- local BlockAnimTrack
- local isBlocking = false
- local function setupBlockAbility(character)
- if not scriptActive then return end
- if BlockConnection then
- BlockConnection:Disconnect()
- BlockConnection = nil
- end
- local humanoid = character:WaitForChild("Humanoid")
- if not BlockAnimTrack then
- local BlockAnim = Instance.new("Animation")
- BlockAnim.AnimationId = "rbxassetid://242455877"
- BlockAnimTrack = humanoid:LoadAnimation(BlockAnim)
- end
- BlockConnection = UserInputService.InputBegan:Connect(function(input, gameProcessed)
- if not scriptActive then return end
- if gameProcessed or isBlocking then return end
- if input.KeyCode ~= Enum.KeyCode.Q then return end
- isBlocking = true
- for _, track in pairs(humanoid:GetPlayingAnimationTracks()) do
- track:Stop()
- end
- BlockAnimTrack:Play()
- BlockAnimTrack:AdjustSpeed(0)
- BlockAnimTrack.TimePosition = 0.41
- humanoid.WalkSpeed = 4
- local function endBlock()
- humanoid.WalkSpeed = 16
- BlockAnimTrack:AdjustSpeed(1)
- BlockAnimTrack:Stop()
- isBlocking = false
- end
- local blockEnd = Instance.new("BindableEvent")
- blockEnd.Event:Connect(endBlock)
- delay(1, function()
- if isBlocking then
- blockEnd:Fire()
- end
- end)
- BlockAnimTrack.Stopped:Connect(function()
- if isBlocking then
- blockEnd:Fire()
- end
- end)
- end)
- end
- -- Function to deactivate the script
- local function deactivateScript()
- scriptActive = false
- if chargeConnection then
- chargeConnection:Disconnect()
- chargeConnection = nil
- end
- if punchConnection then
- punchConnection:Disconnect()
- punchConnection = nil
- end
- if BlockConnection then
- BlockConnection:Disconnect()
- BlockConnection = nil
- end
- if ChargeAnimTrack then
- ChargeAnimTrack:Stop()
- ChargeAnimTrack = nil
- end
- if PunchAnimTrack then
- PunchAnimTrack:Stop()
- PunchAnimTrack = nil
- end
- if BlockAnimTrack then
- BlockAnimTrack:Stop()
- BlockAnimTrack = nil
- end
- isChargeAnimPlaying = false
- isPunchAnimPlaying = false
- isBlockAnimPlaying = false
- end
- if player.Character then
- setupCharacter(player.Character)
- setupPunchAbility(player.Character)
- setupBlockAbility(player.Character)
- end
- player.CharacterAdded:Connect(function(character)
- if scriptActive then
- setupCharacter(character)
- setupPunchAbility(character)
- setupBlockAbility(character)
- end
- end)
- player.CharacterRemoving:Connect(function()
- deactivateScript()
- end)
- game.Destroying:Connect(function()
- deactivateScript()
- end)
- --notify
- local Callback = Instance.new("BindableFunction")
- function Callback.OnInvoke(Button)
- end
- -- create and play a sound
- local sound = Instance.new("Sound")
- sound.SoundId = "rbxassetid://135478009117226"
- sound.Parent = game:GetService("Workspace")
- sound.Volume = 0.5
- sound:Play()
- --notification
- game:GetService("StarterGui"):SetCore("SendNotification", {
- Title = "Guest 1337 moveset",
- Text = "Script Activated. Enjoy! :)\n(resets when u die)",
- Icon = "",
- Duration = 5,
- Callback = Callback,
- Button1 = "OK",
- })
- sound.Ended:Connect(function()
- sound:Destroy()
- end)
- Callback:Destroy()
- --notify
- local Callback = Instance.new("BindableFunction")
- function Callback.OnInvoke(Button)
- end
- -- create and play a sound
- local sound = Instance.new("Sound")
- sound.SoundId = "rbxassetid://135478009117226"
- sound.Parent = game:GetService("Workspace")
- sound.Volume = 0.5
- sound:Play()
- --notification
- game:GetService("StarterGui"):SetCore("SendNotification", {
- Title = "Guest 1337 moveset",
- Text = "(Q - Block)\n(E - Charge)\n(R - Punch)",
- Icon = "",
- Duration = 10,
- Callback = Callback,
- Button1 = "OK",
- })
- sound.Ended:Connect(function()
- sound:Destroy()
- end)
- Callback:Destroy()
Advertisement
Add Comment
Please, Sign In to add comment