-
Notifications
You must be signed in to change notification settings - Fork 85
Description
-- DashClient (R6, standalone)
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local ContextActionService = game:GetService("ContextActionService")
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local root = character:WaitForChild("HumanoidRootPart")
local animator = humanoid:FindFirstChildOfClass("Animator")
if not animator then
animator = Instance.new("Animator")
animator.Parent = humanoid
end
local animationsFolder = script:WaitForChild("Animations")
-- LOAD ANIMATIONS
local tracks = {}
local function loadAnimations()
tracks = {}
for _, anim in ipairs(animationsFolder:GetChildren()) do
if anim:IsA("Animation") then
tracks[anim.Name] = animator:LoadAnimation(anim)
end
end
end
loadAnimations()
-- SETTINGS
local DASH_SPEED = 60
local DASH_TIME = 0.50
local DASH_COOLDOWN = 2
local QUICKSTEP_LEVEL_REQUIREMENT = 5
local canDash = true
local quickstepEffect = game.Workspace:FindFirstChild("Particle effects", true):FindFirstChild("D - QUICKSTEP", true)
-- LEVEL CALCULATION
local function calculateLevel()
local stats = player:FindFirstChild("Stats")
if not stats then return 1 end
local strength = stats:FindFirstChild("Strength")
local speed = stats:FindFirstChild("Speed")
local durability = stats:FindFirstChild("Durability")
local wisdom = stats:FindFirstChild("Wisdom")
if not strength or not speed or not durability or not wisdom then return 1 end
local totalStats = strength.Value + speed.Value + durability.Value + wisdom.Value
local xpPercent = (totalStats / 5) * 0.12
local totalXP = xpPercent * 100
local level = math.floor(totalXP / 100) + 1
return level
end
-- RESPAWN FIX
player.CharacterAdded:Connect(function(char)
character = char
humanoid = char:WaitForChild("Humanoid")
root = char:WaitForChild("HumanoidRootPart")
animator = humanoid:FindFirstChildOfClass("Animator")
if not animator then
animator = Instance.new("Animator")
animator.Parent = humanoid
end
loadAnimations()
end)
-- GET DASH DIRECTION
local function getDashDirection()
-- Get current humanoid to ensure it's updated
local currentHumanoid = character and character:FindFirstChildOfClass("Humanoid")
if not currentHumanoid then
return "DashForward", root.CFrame.LookVector
end
local moveDir = currentHumanoid.MoveDirection
if moveDir.Magnitude == 0 then
return "DashForward", root.CFrame.LookVector
end
local forward = root.CFrame.LookVector
local right = root.CFrame.RightVector
if moveDir:Dot(forward) > 0.7 then
return "DashForward", forward
elseif moveDir:Dot(forward) < -0.7 then
return "DashBackward", -forward
elseif moveDir:Dot(right) > 0 then
return "DashRight", right
else
return "DashLeft", -right
end
end
-- DASH LOGIC
local function dash()
if not canDash then return end
-- Get current character and humanoid
local currentCharacter = player.Character
if not currentCharacter then return end
local currentHumanoid = currentCharacter:FindFirstChildOfClass("Humanoid")
if not currentHumanoid or currentHumanoid.Health <= 0 then return end
local currentRoot = currentCharacter:FindFirstChild("HumanoidRootPart")
if not currentRoot then return end
canDash = false
local animName, dir = getDashDirection()
local track = tracks[animName]
if track then
-- Stop any existing animation before playing
if track.IsPlaying then
track:Stop()
end
track:Play()
print("Playing dash animation:", animName)
else
print("Warning: Dash animation not found:", animName)
end
-- Check for level 5+ quickstep effect
local level = calculateLevel()
local isQuickstep = level >= QUICKSTEP_LEVEL_REQUIREMENT
-- Play quickstep effect if level 5+
if isQuickstep and quickstepEffect then
print("Playing quickstep effect")
local effectClone = quickstepEffect:Clone()
effectClone.Parent = currentRoot
effectClone.CFrame = currentRoot.CFrame
-- Emit particles
for _, child in ipairs(effectClone:GetDescendants()) do
if child:IsA("ParticleEmitter") then
child:Emit(child:GetAttribute("EmitCount") or 10)
end
end
-- Remove effect after dash
task.delay(DASH_TIME, function()
effectClone:Destroy()
end)
else
print("Quickstep effect not playing - level:", level, "requirement:", QUICKSTEP_LEVEL_REQUIREMENT, "effect exists:", quickstepEffect ~= nil)
end
-- Make player invisible during dash (level 5+)
if isQuickstep then
for _, part in ipairs(currentCharacter:GetDescendants()) do
if part:IsA("BasePart") then
part.Transparency = 1
end
end
-- Restore visibility after dash
task.delay(DASH_TIME, function()
for _, part in ipairs(currentCharacter:GetDescendants()) do
if part:IsA("BasePart") and part.Name ~= "HumanoidRootPart" then
part.Transparency = 0
elseif part.Name == "HumanoidRootPart" then
part.Transparency = 1
end
end
end)
end
local bv = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(1e5, 0, 1e5)
bv.Velocity = dir * DASH_SPEED
bv.Parent = currentRoot
task.delay(DASH_TIME, function()
if bv then
bv:Destroy()
end
end)
task.delay(DASH_COOLDOWN, function()
canDash = true
end)
end
-- CONTEXT ACTION (PC + CONSOLE + MOBILE)
local function dashAction(actionName, inputState, inputObject)
if inputState == Enum.UserInputState.Begin then
dash()
end
end
ContextActionService:BindAction(
"DashAction",
dashAction,
true, -- creates mobile button
Enum.KeyCode.Q, -- PC keyboard
Enum.KeyCode.ButtonB -- Xbox B / PlayStation Circle
)
-- MOBILE BUTTON POSITION (OPTIONAL BUT NICE)
ContextActionService:SetPosition(
"DashAction",
UDim2.new(0.85, 0, -1, 0)
)
ContextActionService:SetTitle("DashAction", "Dash")