-- Sprint universal móvil y PC con botón a la derecha pero más arriba para no tapar salto -- Animaciones cool para botón y barra -- CONFIG local sprintKey = Enum.KeyCode.LeftShift local sprintSpeed = 30 local walkSpeed = 16 local maxStamina = 100 local staminaDrain = 20 local staminaRegen = 10 -- SERVICIOS local UserInputService = game:GetService("UserInputService") local RunService = game:GetService("RunService") local Players = game:GetService("Players") local TweenService = game:GetService("TweenService") -- VARIABLES local player = Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") local stamina = maxStamina local isSprinting = false local staminaEmpty = false -- GUI local screenGui = Instance.new("ScreenGui") screenGui.Name = "SprintGUI" screenGui.Parent = game.CoreGui screenGui.ResetOnSpawn = false -- Barra de stamina (abajo centrada) local staminaBarBG = Instance.new("Frame") staminaBarBG.Size = UDim2.new(0, 320, 0, 25) staminaBarBG.Position = UDim2.new(0.5, -160, 0.9, 0) staminaBarBG.BackgroundColor3 = Color3.fromRGB(30, 30, 30) staminaBarBG.BorderSizePixel = 0 staminaBarBG.AnchorPoint = Vector2.new(0, 0) staminaBarBG.Parent = screenGui local border = Instance.new("UIStroke") border.Color = Color3.fromRGB(200, 200, 200) border.Thickness = 1.5 border.Parent = staminaBarBG local bgCorner = Instance.new("UICorner") bgCorner.CornerRadius = UDim.new(0, 12) bgCorner.Parent = staminaBarBG local staminaBar = Instance.new("Frame") staminaBar.Size = UDim2.new(1, 0, 1, 0) staminaBar.BackgroundColor3 = Color3.fromRGB(50, 200, 50) staminaBar.BorderSizePixel = 0 staminaBar.AnchorPoint = Vector2.new(0, 0) staminaBar.Position = UDim2.new(0, 0, 0, 0) staminaBar.Parent = staminaBarBG local staminaCorner = Instance.new("UICorner") staminaCorner.CornerRadius = UDim.new(0, 12) staminaCorner.Parent = staminaBar local staminaLabel = Instance.new("TextLabel") staminaLabel.Size = UDim2.new(1, 0, 0, 20) staminaLabel.Position = UDim2.new(0.5, 0, 0, -22) staminaLabel.BackgroundTransparency = 1 staminaLabel.Text = "Stamina" staminaLabel.Font = Enum.Font.GothamBold staminaLabel.TextSize = 18 staminaLabel.TextColor3 = Color3.fromRGB(220, 220, 220) staminaLabel.AnchorPoint = Vector2.new(0.5, 0) staminaLabel.Parent = staminaBarBG -- Botón sprint móvil (ancla arriba-izquierda para controlar posición solo con offset) local mobileButton = Instance.new("TextButton") mobileButton.Size = UDim2.new(0, 130, 0, 60) mobileButton.AnchorPoint = Vector2.new(0, 0) mobileButton.Position = UDim2.new(1, -10, 1, -220) -- pegado a la derecha, más arriba para no tapar salto mobileButton.BackgroundColor3 = Color3.fromRGB(255, 140, 0) mobileButton.TextColor3 = Color3.fromRGB(255, 255, 255) mobileButton.Font = Enum.Font.GothamSemibold mobileButton.TextSize = 24 mobileButton.Text = "Sprint" mobileButton.AutoButtonColor = true mobileButton.Parent = screenGui local buttonCorner = Instance.new("UICorner") buttonCorner.CornerRadius = UDim.new(0, 18) buttonCorner.Parent = mobileButton local buttonShadow = Instance.new("ImageLabel") buttonShadow.Name = "Shadow" buttonShadow.BackgroundTransparency = 1 buttonShadow.Image = "rbxassetid://6014261992" buttonShadow.ImageColor3 = Color3.new(0,0,0) buttonShadow.ImageTransparency = 0.7 buttonShadow.Size = UDim2.new(1.3, 0, 1.3, 0) buttonShadow.Position = UDim2.new(-0.15, 0, -0.15, 0) buttonShadow.ZIndex = 0 buttonShadow.Parent = mobileButton -- Animación pulso botón (crece y cambia color) local pulseTweenInfo = TweenInfo.new(0.6, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true) local pulseTweenSize = TweenService:Create(mobileButton, pulseTweenInfo, {Size = UDim2.new(0, 140, 0, 65)}) local pulseTweenColor = TweenService:Create(mobileButton, pulseTweenInfo, {BackgroundColor3 = Color3.fromRGB(255, 180, 50)}) -- FUNCIONES local function startSprint() if stamina > 0 and not staminaEmpty then isSprinting = true humanoid.WalkSpeed = sprintSpeed pulseTweenSize:Play() pulseTweenColor:Play() end end local function stopSprint() isSprinting = false humanoid.WalkSpeed = walkSpeed pulseTweenSize:Cancel() pulseTweenColor:Cancel() mobileButton.Size = UDim2.new(0, 130, 0, 60) mobileButton.BackgroundColor3 = Color3.fromRGB(255, 140, 0) end local function updateButtonState() if staminaEmpty then mobileButton.AutoButtonColor = false mobileButton.BackgroundColor3 = Color3.fromRGB(120, 120, 120) mobileButton.TextColor3 = Color3.fromRGB(200, 200, 200) mobileButton.Active = false stopSprint() else mobileButton.AutoButtonColor = true mobileButton.BackgroundColor3 = Color3.fromRGB(255, 140, 0) mobileButton.TextColor3 = Color3.fromRGB(255, 255, 255) mobileButton.Active = true end end -- ACTUALIZACIÓN DE BARRA Y COLOR RunService.RenderStepped:Connect(function(dt) if isSprinting and stamina > 0 then stamina = math.max(stamina - staminaDrain * dt, 0) if stamina <= 0 then staminaEmpty = true stopSprint() end elseif not isSprinting and stamina < maxStamina then stamina = math.min(stamina + staminaRegen * dt, maxStamina) if stamina > 0 then staminaEmpty = false end end -- Color barra verde a rojo local t = stamina / maxStamina local r = 255 * (1 - t) local g = 200 * t + 50 staminaBar.BackgroundColor3 = Color3.fromRGB(r, g, 0) -- Animación suavizada de tamaño barra staminaBar:TweenSize(UDim2.new(t, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.15, true) updateButtonState() end) -- INPUTS UserInputService.InputBegan:Connect(function(input, gp) if not gp and input.KeyCode == sprintKey then startSprint() end end) UserInputService.InputEnded:Connect(function(input) if input.KeyCode == sprintKey then stopSprint() end end) mobileButton.MouseButton1Down:Connect(startSprint) mobileButton.MouseButton1Up:Connect(stopSprint) -- RESET AL REAPARECER player.CharacterAdded:Connect(function(newChar) character = newChar humanoid = character:WaitForChild("Humanoid") stopSprint() stamina = maxStamina staminaEmpty = false end)