-- this dash and stamina system was made by the_randomguy413 and was made with the help of ai -- youtube: @Therandomguy413 (pls sub) -- SERVICES local Players = game:GetService("Players") local UIS = game:GetService("UserInputService") local TweenService = game:GetService("TweenService") local Debris = game:GetService("Debris") local ContentProvider = game:GetService("ContentProvider") local Camera = workspace.CurrentCamera local RunService = game:GetService("RunService") -- PLAYER local player = Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid local root local canDash = true local airDashUsed = false --------------------------------------------------- -- ⚙️ DASH CONFIG (EASY TO TUNE) --------------------------------------------------- -- Ground dash local DASH_SPEED = 52.8 -- forward speed local DASH_TIME = 0.35 -- duration (seconds) -- Air dash local AIR_DASH_SPEED_MULT = 1.3 -- forward speed multiplier local AIR_DASH_UP_FORCE = 4 -- upward push (keep low) local AIR_DASH_TIME = 0.39 -- slightly shorter than ground dash -- Cooldown & camera local COOLDOWN = 1.4 -- time befor dash is ready local FOV_BOOST = 25 -- how much fov boost you get when you dash --------------------------------------------------- -- 🔋 STAMINA SETTINGS --------------------------------------------------- local MAX_STAMINA = 150 -- your max stamina local DASH_STAMINA_COST = 30 -- how much stamina dash cost local AIR_DASH_STAMINA_COST = 50 -- air dash costs local STAMINA_REGEN = 25 -- per second local STAMINA_REGEN_DELAY = 2.5 -- after dash local stamina = MAX_STAMINA local lastDashTime = 0 --------------------------------------------------- -- 📱 MOBILE CHECK --------------------------------------------------- local isMobile = UIS.TouchEnabled --------------------------------------------------- -- 📱 MOBILE GUI (IMAGE + POP + COOLDOWN FADE + AIR DASH GLOW) --------------------------------------------------- local dashButton local glowStroke if isMobile then local gui = Instance.new("ScreenGui") gui.Name = "DashGui" gui.ResetOnSpawn = false gui.Parent = player:WaitForChild("PlayerGui") dashButton = Instance.new("ImageButton") dashButton.Size = UDim2.new(0, 70, 0, 70) -- size of pic dashButton.Position = UDim2.new(0.7, 0, 0.60, 0) -- position of pic dashButton.BackgroundTransparency = 1 dashButton.Image = "rbxassetid://13213984187" -- picture id for mobile ui dashButton.Parent = gui -- EXTRA STRONG GLOW STROKE glowStroke = Instance.new("UIStroke") glowStroke.Color = Color3.fromRGB(0, 200, 255) glowStroke.Thickness = 8 glowStroke.Transparency = 0.3 glowStroke.Enabled = false glowStroke.Parent = dashButton -- Pop animation function local function popAnimation() local shrink = TweenService:Create(dashButton, TweenInfo.new(0.08, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), { Size = UDim2.new(0, 50, 0, 50) }) shrink:Play() shrink.Completed:Wait() TweenService:Create(dashButton, TweenInfo.new(0.12, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out), { Size = UDim2.new(0, 70, 0, 70) }):Play() end dashButton.MouseButton1Click:Connect(popAnimation) end --------------------------------------------------- -- 🔋 STAMINA UI (PC + MOBILE) --------------------------------------------------- local staminaGui = Instance.new("ScreenGui") staminaGui.Name = "StaminaGui" staminaGui.ResetOnSpawn = false staminaGui.Parent = player:WaitForChild("PlayerGui") local staminaFrame = Instance.new("Frame") staminaFrame.AnchorPoint = Vector2.new(0.5, 1) staminaFrame.BackgroundColor3 = Color3.fromRGB(20, 20, 20) staminaFrame.BorderSizePixel = 0 staminaFrame.Parent = staminaGui Instance.new("UICorner", staminaFrame).CornerRadius = UDim.new(1, 0) local staminaBar = Instance.new("Frame") staminaBar.Size = UDim2.new(1, 0, 1, 0) staminaBar.BackgroundColor3 = Color3.fromRGB(0, 200, 255) staminaBar.BorderSizePixel = 0 staminaBar.Parent = staminaFrame Instance.new("UICorner", staminaBar).CornerRadius = UDim.new(1, 0) if isMobile then -- 📱 MOBILE SETTINGS staminaFrame.Position = UDim2.new(0.5, 0, 0.79, 0) -- position of stamina bar on mobile staminaFrame.Size = UDim2.new(0.4, 0, 0.03, 0) -- size of stamina bar on mobile else -- 🖥️ PC SETTINGS staminaFrame.Position = UDim2.new(0.5, 0, 0.83, 0) -- position of stamina bar on pc staminaFrame.Size = UDim2.new(0.32, 0, 0.03, 0) -- size of stamina bar on pc end local staminaTween local STAMINA_TWEEN_TIME = 0.19 -- how smooth the animation is local function updateStaminaUI() local targetSize = UDim2.new(stamina / MAX_STAMINA, 0, 1, 0) if staminaTween then staminaTween:Cancel() end staminaTween = TweenService:Create( staminaBar, TweenInfo.new(STAMINA_TWEEN_TIME, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), { Size = targetSize } ) staminaTween:Play() if stamina <= 50 then -- how much stamina for bar to become very low stamina coulour staminaBar.BackgroundColor3 = Color3.fromRGB(220, 50, 50) -- coulour of very low stamina elseif stamina <= 75 then -- how much stamina for bar to become low stamina coulour staminaBar.BackgroundColor3 = Color3.fromRGB(255, 140, 0) -- coulour of low stamina else staminaBar.BackgroundColor3 = Color3.fromRGB(0, 200, 255) -- coulour ofhigh stamina end end updateStaminaUI() --------------------------------------------------- -- 🔊 SOUND EFFECTS --------------------------------------------------- local function newSound(id, volume, speed) local s = Instance.new("Sound") s.SoundId = id s.Volume = volume s.PlaybackSpeed = speed or 1 s.RollOffMode = Enum.RollOffMode.Inverse s.RollOffMaxDistance = 120 s.Looped = false return s end local dashStartSound = newSound("rbxassetid://1520977170", 1.3, 1.05) -- sound id 1 local dashEndSound = newSound("rbxassetid://858508159", 1.1, 1) -- sound id 2 --------------------------------------------------- -- 🎬 CHARACTER SETUP --------------------------------------------------- local dashTrack local function setupCharacter(char) character = char humanoid = character:WaitForChild("Humanoid") root = character:WaitForChild("HumanoidRootPart") -- RESET AIR DASH WHEN LANDING humanoid.StateChanged:Connect(function(_, newState) if newState == Enum.HumanoidStateType.Landed then airDashUsed = false end end) dashStartSound.Parent = root dashEndSound.Parent = root ContentProvider:PreloadAsync({dashStartSound, dashEndSound}) local dashAnim = Instance.new("Animation") dashAnim.AnimationId = "rbxassetid://000000000000" -- your own animimation id dashTrack = humanoid:LoadAnimation(dashAnim) dashTrack.Priority = Enum.AnimationPriority.Action end setupCharacter(character) player.CharacterAdded:Connect(setupCharacter) --------------------------------------------------- -- ✨ DASH VFX (Wind streaks and trails) --------------------------------------------------- local function dashVFX() for i = 1, 10 do local streak = Instance.new("Part") streak.Size = Vector3.new(0.15, 0.15, math.random(8, 14)) streak.CFrame = root.CFrame * CFrame.new( math.random(-2, 2), math.random(-1, 1), -math.random(4, 8) ) streak.Anchored = true streak.CanCollide = false streak.Material = Enum.Material.Neon streak.Color = Color3.fromRGB(255, 255, 255) streak.Transparency = 0.2 streak.Parent = workspace TweenService:Create( streak, TweenInfo.new(0.3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {Transparency = 1, Size = Vector3.new(0.15, 0.15, streak.Size.Z * 1.6)} ):Play() Debris:AddItem(streak, 0.35) end local a0 = Instance.new("Attachment") a0.Parent = root local a1 = Instance.new("Attachment") a1.Position = Vector3.new(0, 0, -2) a1.Parent = root local trail = Instance.new("Trail") trail.Attachment0 = a0 trail.Attachment1 = a1 trail.Parent = root trail.Lifetime = NumberRange.new(0.3) trail.Color = ColorSequence.new(Color3.fromRGB(255, 255, 255)) trail.Transparency = NumberSequence.new(0.5) trail.Enabled = true trail.Texture = "rbxassetid://1234567890" Debris:AddItem(trail, 0.5) end --------------------------------------------------- -- 🎥 FOV EFFECT --------------------------------------------------- local function fovEffect() local original = Camera.FieldOfView TweenService:Create(Camera, TweenInfo.new(0.08), { FieldOfView = original + FOV_BOOST }):Play() task.delay(0.25, function() TweenService:Create(Camera, TweenInfo.new(0.2), { FieldOfView = original }):Play() end) end --------------------------------------------------- -- 🧱 WALL DETECTION --------------------------------------------------- local RayParams = RaycastParams.new() RayParams.FilterType = Enum.RaycastFilterType.Blacklist RayParams.IgnoreWater = true local function startWallDetection(velocity, duration) RayParams.FilterDescendantsInstances = {character} local connection connection = RunService.Heartbeat:Connect(function() if not velocity or not velocity.Parent then connection:Disconnect() return end local result = workspace:Raycast( root.Position, root.CFrame.LookVector * 3.5, RayParams ) if result and result.Instance and result.Instance.CanCollide then velocity:Destroy() connection:Disconnect() end end) task.delay(duration, function() if connection then connection:Disconnect() end end) end --------------------------------------------------- -- AIR DASH GLOW (mobile UI) --------------------------------------------------- local pulseTween local function setDashGlow(enabled) if not dashButton then return end if enabled then -- instant blue (no fade) dashButton.ImageColor3 = Color3.fromRGB(8, 255, 247) if glowStroke then glowStroke.Enabled = true end if not pulseTween then pulseTween = TweenService:Create( dashButton, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true), { ImageColor3 = Color3.fromRGB(0, 200, 255) } ) pulseTween:Play() end else if pulseTween then pulseTween:Cancel() pulseTween = nil end dashButton.ImageColor3 = Color3.fromRGB(255, 255, 255) if glowStroke then glowStroke.Enabled = false end end end RunService.Heartbeat:Connect(function() if humanoid and dashButton then local inAir = humanoid.FloorMaterial == Enum.Material.Air if inAir and canDash and not airDashUsed then setDashGlow(true) else setDashGlow(false) end end end) --------------------------------------------------- -- 🔋 STAMINA REGEN --------------------------------------------------- RunService.Heartbeat:Connect(function(dt) if tick() - lastDashTime > STAMINA_REGEN_DELAY then stamina = math.clamp(stamina + STAMINA_REGEN * dt, 0, MAX_STAMINA) updateStaminaUI() end end) --------------------------------------------------- -- ⚡ DASH FUNCTION --------------------------------------------------- local function dash() if not humanoid or humanoid.Health <= 0 then return end local inAir = humanoid.FloorMaterial == Enum.Material.Air local requiredStamina = (inAir and not airDashUsed) and AIR_DASH_STAMINA_COST or DASH_STAMINA_COST if not canDash or not root or stamina < requiredStamina then return end canDash = false stamina -= requiredStamina lastDashTime = tick() updateStaminaUI() local velocity = Instance.new("BodyVelocity") velocity.MaxForce = Vector3.new(1e5, 1e5, 1e5) local dashDuration = DASH_TIME velocity.Velocity = root.CFrame.LookVector * DASH_SPEED if inAir and not airDashUsed then airDashUsed = true setDashGlow(false) dashDuration = AIR_DASH_TIME velocity.Velocity = root.CFrame.LookVector * (DASH_SPEED * AIR_DASH_SPEED_MULT) + Vector3.new(0, AIR_DASH_UP_FORCE, 0) end velocity.Parent = root startWallDetection(velocity, dashDuration) Debris:AddItem(velocity, dashDuration) -- Play animation, VFX, sound if dashTrack then dashTrack:Play(0.05, 1, 1) end dashStartSound:Play() dashVFX() fovEffect() -- Mobile pop animation if dashButton then local pop = TweenService:Create(dashButton, TweenInfo.new(0.08, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), { Size = UDim2.new(0, 50, 0, 50) }) pop:Play() pop.Completed:Connect(function() TweenService:Create(dashButton, TweenInfo.new(0.12, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out), { Size = UDim2.new(0, 70, 0, 70) }):Play() end) TweenService:Create(dashButton, TweenInfo.new(0.1), {ImageTransparency = 0.5}):Play() end task.delay(dashDuration, function() dashEndSound:Play() end) task.delay(COOLDOWN, function() canDash = true if not inAir then airDashUsed = false end if dashButton then TweenService:Create(dashButton, TweenInfo.new(0.1), {ImageTransparency = 0}):Play() end end) end --------------------------------------------------- -- INPUT --------------------------------------------------- if dashButton then dashButton.MouseButton1Click:Connect(dash) end UIS.InputBegan:Connect(function(input, gp) if gp then return end if input.KeyCode == Enum.KeyCode.Q then dash() end end)