Dash Script with Afterimages
Key RequiredUniversal

Dash Script with Afterimages

Universal Scriptwg609420wg609420 20.9K views 578 executesUpdated Dec 28, 2024
5.0/ 5(3 votes)
30100% Positive
Lua Script•388 lines (13823 chars)
-- NOT FE fyi
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local CollectionService = game:GetService("CollectionService")

-- Configuration
local DASH_KEY = Enum.KeyCode.Q
local INITIAL_DASH_POWER = 125    
local DASH_DURATION = 0.5       
local DASH_COOLDOWN = 0
local MIN_VELOCITY = 5
local TURN_SPEED = 0.75          
local DECELERATION = 1        
local START_DELAY = 0        -- Initial pause duration
local STOP_POINT = 0.5        -- Point where dash stops (50%)
local SLOWDOWN_START = 0.6    -- Point where slowdown begins (60%)
local STOP_DURATION = 0.05     
local AFTERIMAGE_TRANSPARENCY = 0.7      -- Starting transparency for afterimages
local AFTERIMAGE_LIFETIME = 10     -- Longer lifetime to see the full trail
local AFTERIMAGE_INTERVAL = 0.001    -- More frequent afterimages
local DASH_COLOR = Color3.fromRGB(85, 0, 128)  -- White color for effects
local USE_ORIGINAL_COLORS = true         -- Toggle between white afterimages and original colors
local SANDEVISTAN_MODE = true        -- Toggle Sandevistan effect
local SANDEVISTAN_COLORS = {
    Color3.fromRGB(0, 115, 115),    -- Start with Cyan
    Color3.fromRGB(77, 0, 115),    -- Transition to Purple
    Color3.fromRGB(115, 0, 0),      -- Then Red
    Color3.fromRGB(115, 115, 0),    -- To Yellow
    Color3.fromRGB(0, 115, 0)       -- End with Green
}
local MAX_AFTERIMAGES = 20         -- More afterimages for smoother gradient
local CHROMATIC_OFFSET = 0.2         -- How far the color separations are offset

-- Variables
local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Root = Character:WaitForChild("HumanoidRootPart")
local Camera = workspace.CurrentCamera

local canDash = true
local isDashing = false
local dashVelocity = Vector3.new(0, 0, 0)
local initialDashDir = Vector3.new(0, 0, 0)

-- Create effects folder
local effectsFolder = Instance.new("Folder")
effectsFolder.Name = "DashEffects"
effectsFolder.Parent = workspace

-- Function to get dash direction
local function getDashDirection()
    local moveDir = Humanoid.MoveDirection
    
    -- If player isn't moving, use camera direction
    if moveDir.Magnitude == 0 then
        local camLook = Camera.CFrame.LookVector
        moveDir = Vector3.new(camLook.X, 0, camLook.Z)
    end
    
    return moveDir.Unit
end

-- Add this function after the getDashDirection function
local function getGradientColor(index, total)
    -- Reverse the index so newest afterimages start with cyan
    index = total - index + 1
    
    local colorCount = #SANDEVISTAN_COLORS
    local position = ((index-1) / (total-1)) * (colorCount-1)
    local colorIndex = math.floor(position) + 1
    local nextColorIndex = math.min(colorIndex + 1, colorCount)
    local lerpAmount = position - math.floor(position)
    
    local color1 = SANDEVISTAN_COLORS[colorIndex]
    local color2 = SANDEVISTAN_COLORS[nextColorIndex]
    
    -- Smoother color lerp
    return Color3.new(
        color1.R + (color2.R - color1.R) * lerpAmount,
        color1.G + (color2.G - color1.G) * lerpAmount,
        color1.B + (color2.B - color1.B) * lerpAmount
    )
end

-- Modify the createAfterimage function
local function createAfterimage(character, afterimageCount)
    local clone = Instance.new("Model")
    clone.Name = "DashAfterimage"
    
    local rootPart = character:FindFirstChild("HumanoidRootPart")
    if not rootPart then return end
    
    local rootCFrame = rootPart.CFrame
    
    for _, part in pairs(character:GetDescendants()) do
        if part:IsA("BasePart") and part.Transparency < 1 then
            local clonePart = part:Clone()
            
            -- Remove any scripts, joints, etc.
            for _, child in pairs(clonePart:GetChildren()) do
                if not child:IsA("SpecialMesh") and 
                   not child:IsA("Texture") and 
                   not child:IsA("Decal") then
                    child:Destroy()
                end
            end
            
            -- Set properties
            clonePart.CanCollide = false
            clonePart.CanQuery = false
            clonePart.CanTouch = false
            clonePart.Anchored = true
            
            if SANDEVISTAN_MODE then
                clonePart.Material = Enum.Material.Neon
                -- Get color based on afterimage position
                clonePart.Color = getGradientColor(afterimageCount, MAX_AFTERIMAGES)
                clonePart.Transparency = AFTERIMAGE_TRANSPARENCY
            else
                if USE_ORIGINAL_COLORS then
                    clonePart.Transparency = AFTERIMAGE_TRANSPARENCY
                else
                    clonePart.Transparency = AFTERIMAGE_TRANSPARENCY
                    clonePart.Color = Color3.fromRGB(255, 255, 255)
                    clonePart.Material = Enum.Material.Neon
                end
            end
            
            CollectionService:AddTag(clonePart, "DashEffect")
            
            clonePart.CFrame = rootCFrame:ToWorldSpace(rootPart.CFrame:ToObjectSpace(part.CFrame))
            clonePart.Parent = clone
        end
    end
    
    clone.Parent = effectsFolder
    
    -- Fade out and destroy
    game:GetService("Debris"):AddItem(clone, AFTERIMAGE_LIFETIME)
    
    -- Fade out effect
    local startTime = tick()
    local connection
    connection = RunService.Heartbeat:Connect(function()
        local elapsed = tick() - startTime
        if elapsed >= AFTERIMAGE_LIFETIME then
            connection:Disconnect()
            return
        end
        
        local fadeProgress = elapsed / AFTERIMAGE_LIFETIME
        for _, part in pairs(clone:GetDescendants()) do
            if part:IsA("BasePart") then
                part.Transparency = AFTERIMAGE_TRANSPARENCY + ((1 - AFTERIMAGE_TRANSPARENCY) * fadeProgress)
            end
        end
    end)
end

-- Add these functions after createAfterimage function
local function createDashRing()
    local ring = Instance.new("Part")
    ring.Size = Vector3.new(1, 1, 1)
    ring.Transparency = 0.5
    ring.CanCollide = false
    ring.CanQuery = false
    ring.CanTouch = false
    ring.Anchored = true
    ring.Material = Enum.Material.Neon
    ring.Color = DASH_COLOR
    CollectionService:AddTag(ring, "DashEffect")
    
    -- Create mesh for ring effect
    local mesh = Instance.new("SpecialMesh")
    mesh.MeshType = Enum.MeshType.FileMesh
    mesh.MeshId = "rbxassetid://3270017"  -- Ring mesh
    mesh.Scale = Vector3.new(0, 0, 0)
    mesh.Parent = ring
    
    ring.Parent = effectsFolder
    
    -- Animate ring expansion
    local tweenInfo = TweenInfo.new(0.3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
    local tween = game:GetService("TweenService"):Create(mesh, tweenInfo, {
        Scale = Vector3.new(5, 5, 5)
    })
    tween:Play()
    
    -- Fade out
    local fadeTween = game:GetService("TweenService"):Create(ring, tweenInfo, {
        Transparency = 1
    })
    fadeTween:Play()
    
    game:GetService("Debris"):AddItem(ring, 0.3)
    return ring
end

-- Modify the dash function to track afterimage count
local function dash()
    if not canDash or isDashing then return end
    
    -- Start dash
    canDash = false
    isDashing = true
    dashVelocity = Vector3.new(0, 0, 0)
    
    -- Create visual effects
    createDashRing()  -- Create initial ring
    
    -- Store initial dash direction
    initialDashDir = getDashDirection()
    
    -- Visual effect
    local dashEffect = Instance.new("Trail")
    dashEffect.Color = ColorSequence.new(Color3.fromRGB(255, 255, 255))
    dashEffect.Transparency = NumberSequence.new(0.7)
    dashEffect.Lifetime = 0.2
    CollectionService:AddTag(dashEffect, "DashEffect")
    
    local attachment0 = Instance.new("Attachment")
    local attachment1 = Instance.new("Attachment")
    attachment0.Position = Vector3.new(0, -1, 0)
    attachment1.Position = Vector3.new(0, 1, 0)
    
    CollectionService:AddTag(attachment0, "DashEffect")
    CollectionService:AddTag(attachment1, "DashEffect")
    
    attachment0.Parent = Root
    attachment1.Parent = Root
    dashEffect.Attachment0 = attachment0
    dashEffect.Attachment1 = attachment1
    dashEffect.Parent = Root
    
    local lastAfterimage = 0
    local afterimageCount = 0
    
    -- Dash motion
    local dashStart = tick()
    local connection
    connection = RunService.Heartbeat:Connect(function(delta)
        if not isDashing then
            connection:Disconnect()
            dashEffect:Destroy()
            attachment0:Destroy()
            attachment1:Destroy()
            return
        end
        
        local elapsed = tick() - dashStart
        
        -- Create afterimage if enough time has passed
        if elapsed >= START_DELAY / DASH_DURATION and  -- Only create afterimages after initial pause
           tick() - lastAfterimage >= AFTERIMAGE_INTERVAL then
            afterimageCount = (afterimageCount % MAX_AFTERIMAGES) + 1
            createAfterimage(Character, afterimageCount)
            lastAfterimage = tick()
        end
        
        -- Create ring effect at certain points
        if elapsed >= DASH_DURATION then
            -- Clean up effects
            
            -- End dash
            isDashing = false
            connection:Disconnect()
            dashEffect:Destroy()
            attachment0:Destroy()
            attachment1:Destroy()
            
            -- Complete stop
            if Humanoid then
                Humanoid.WalkSpeed = 0  -- Disable movement
                task.delay(STOP_DURATION, function()
                    if Humanoid then
                        Humanoid.WalkSpeed = 16  -- Reset to default walk speed
                        -- Start cooldown
                        task.delay(DASH_COOLDOWN, function()
                            canDash = true
                        end)
                    end
                end)
            end
            return
        end
        
        -- Calculate dash progress (0 to 1)
        local progress = elapsed / DASH_DURATION
        
        -- Get current desired direction
        local currentDir = getDashDirection()
        
        -- Update velocity based on phase of dash
        if progress < START_DELAY / DASH_DURATION then
            -- Initial pause phase
            dashVelocity = Vector3.new(0, 0, 0)
        elseif progress < STOP_POINT then
            -- Acceleration phase
            local accelerationProgress = (progress - START_DELAY / DASH_DURATION) / (STOP_POINT - START_DELAY / DASH_DURATION)
            local speedFactor = accelerationProgress * (2 - accelerationProgress)  -- Smooth acceleration curve
            local targetVelocity = currentDir * (INITIAL_DASH_POWER * speedFactor)
            dashVelocity = dashVelocity:Lerp(targetVelocity, TURN_SPEED * delta * 60)
        elseif progress < SLOWDOWN_START then
            -- Maintain velocity phase
            local targetVelocity = currentDir * INITIAL_DASH_POWER
            dashVelocity = dashVelocity:Lerp(targetVelocity, TURN_SPEED * delta * 60)
        else
            -- Deceleration phase
            local slowdownProgress = (progress - SLOWDOWN_START) / (1 - SLOWDOWN_START)
            local slowdownFactor = (1 - slowdownProgress) ^ 2
            local targetVelocity = currentDir * (INITIAL_DASH_POWER * slowdownFactor)
            dashVelocity = dashVelocity:Lerp(targetVelocity, TURN_SPEED * delta * 60)
        end
        
        -- Apply velocity
        if Root then
            -- Move character
            Root.CFrame = Root.CFrame + dashVelocity * delta
            
            -- Update character facing direction
            if dashVelocity.Magnitude > MIN_VELOCITY then
                local lookAt = Root.Position + dashVelocity.Unit
                Root.CFrame = CFrame.lookAt(Root.Position, Vector3.new(lookAt.X, Root.Position.Y, lookAt.Z))
            end
        end
    end)
end

-- Input handling (changed to toggle)
local isKeyDown = false
UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if not gameProcessed and input.KeyCode == DASH_KEY then
        isKeyDown = true
        dash()  -- Dash immediately when key is pressed
    end
end)

UserInputService.InputEnded:Connect(function(input, gameProcessed)
    if input.KeyCode == DASH_KEY then
        isKeyDown = false
    end
end)

-- Character respawn handling
LocalPlayer.CharacterAdded:Connect(function(newCharacter)
    Character = newCharacter
    Humanoid = Character:WaitForChild("Humanoid")
    Root = Character:WaitForChild("HumanoidRootPart")
    canDash = true
    isDashing = false
    
    -- Clean up any remaining effects
    for _, effect in pairs(CollectionService:GetTagged("DashEffect")) do
        effect:Destroy()
    end
end)

-- Optional: UI to show cooldown
local function createCooldownUI()
    local screenGui = Instance.new("ScreenGui")
    local frame = Instance.new("Frame")
    local text = Instance.new("TextLabel")
    
    screenGui.Parent = LocalPlayer.PlayerGui
    
    frame.Size = UDim2.new(0, 100, 0, 30)
    frame.Position = UDim2.new(0.5, -50, 0.9, -15)
    frame.BackgroundTransparency = 0.5
    frame.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
    frame.Parent = screenGui
    
    text.Size = UDim2.new(1, 0, 1, 0)
    text.BackgroundTransparency = 1
    text.TextColor3 = Color3.fromRGB(255, 255, 255)
    text.Text = "Dash Ready"
    text.Parent = frame
    
    RunService.Heartbeat:Connect(function()
        text.Text = canDash and "Dash Ready" or "Dash Cooling Down"
    end)
end

createCooldownUI()

print("TSB-Style Dash Script Loaded!")
print("Press Q to dash")

Features & Information

NOT FE, sorry - [Keybind] to dash - WASD will change the direction of the dash, and so will aiming your camera - VERY VERY GLITCHY, may fling you somewhere far - looks cool - Editable dash power, length, cooldown, slowdown and endlag (like in TSB) - Editable afterimage color, duration, length and gradient

Community Comments (8)

ApparentlySpooksApparentlySpooksDec 28, 2024(edited)

is it fe?

csenkeyccsenkeycDec 28, 2024(edited)

bro your the GOAT you dont know HOW long i been looking for this THANK YOU

dextasmorgandextasmorganDec 28, 2024(edited)

i dont think its fe sorry man ApparentlySpooks

jackypoggers69jackypoggers69Dec 28, 2024(edited)

Try to make this to mobile support or a tool while ur holding it your still in the sandevistan mode

wg609420wg609420Dec 30, 2024(edited)

not FE, you could possibly edit the code yourself so it only gives you the afterimages for the sandevistan mode and doesnt dash it would only be FE with backdoors or something

Star_EternalStar_EternalJan 10, 2025(edited)

is is visable to others?

RedPr0sedRedPr0sedMar 22, 2026

Can you make mobile ver?

Miggy192Miggy192Jun 7, 2026

Server sided?

More Scripts for Universal Scripts