local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local Lighting = game:GetService("Lighting")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
-- Dash Settings
local dashing = false
local dashCooldown = false
local DASH_DISTANCE = 50
local DASH_TIME = 0.15
local COOLDOWN_TIME = 1
-- Motion Blur
local blur = Instance.new("BlurEffect")
blur.Size = 0
blur.Parent = Lighting
-- Cooldown UI
local screenGui = Instance.new("ScreenGui", player:WaitForChild("PlayerGui"))
screenGui.Name = "DashCooldownUI"
local barBackground = Instance.new("Frame", screenGui)
barBackground.Size = UDim2.new(0, 200, 0, 20)
barBackground.Position = UDim2.new(0.5, -100, 0.9, 0)
barBackground.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
local cooldownBar = Instance.new("Frame", barBackground)
cooldownBar.Size = UDim2.new(1, 0, 1, 0)
cooldownBar.BackgroundColor3 = Color3.fromRGB(0, 170, 255)
-- Trail Setup
local function addTrail()
local trail = Instance.new("Trail")
trail.Color = ColorSequence.new{
ColorSequenceKeypoint.new(0, Color3.fromRGB(0, 255, 255)),
ColorSequenceKeypoint.new(1, Color3.fromRGB(0, 255, 0))
}
trail.Lifetime = 0.2
trail.MinLength = 0.1
trail.WidthScale = NumberSequence.new(1)
local a0 = Instance.new("Attachment", humanoidRootPart)
local a1 = Instance.new("Attachment", humanoidRootPart)
a0.Position = Vector3.new(0, 1, 0)
a1.Position = Vector3.new(0, -1, 0)
trail.Attachment0 = a0
trail.Attachment1 = a1
trail.Parent = humanoidRootPart
return trail
end
-- Dash Function
local function dash()
if dashing or dashCooldown then return end
dashing = true
dashCooldown = true
-- Enable motion blur
blur.Size = 25
-- Add trail
local trail = addTrail()
-- Tween cooldown bar
cooldownBar.Size = UDim2.new(0, 0, 1, 0)
TweenService:Create(cooldownBar, TweenInfo.new(COOLDOWN_TIME), {Size = UDim2.new(1, 0, 1, 0)}):Play()
local direction = humanoidRootPart.CFrame.LookVector
local startTime = tick()
local connection
connection = RunService.RenderStepped:Connect(function()
local elapsed = tick() - startTime
if elapsed >= DASH_TIME then
humanoidRootPart.Velocity = Vector3.zero
connection:Disconnect()
dashing = false
blur.Size = 0
if trail then trail:Destroy() end
task.delay(COOLDOWN_TIME, function()
dashCooldown = false
end)
return
end
humanoidRootPart.Velocity = direction * (DASH_DISTANCE / DASH_TIME)
end)
end
-- Keybind
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.F then
dash()
end
end)
Comments
is ts ai generated?
Amazing script, Hopefully can be edited to go where the camera is looking, Instead of just dashing the player forward.
im gonna add a speed, cooldown, and dash length changer gui for QOL