local DashEvent = script.Parent
-- Reusable easing function
local function applyEasedVelocity(bv: BodyVelocity, direction: Vector3, strength: number, duration: number)
local steps = 10
local rate = duration / steps
for i = 1, steps do
local t = i / steps
local easeOut = (1 - t)^2
local currentSpeed = strength * easeOut
bv.Velocity = direction.Unit * currentSpeed
task.wait(rate)
end
bv:Destroy()
end
DashEvent.OnServerEvent:Connect(function(Player, DashButton)
local Character = Player.Character
local Hum = Character:FindFirstChild("Humanoid")
local HumRp = Character:FindFirstChild("HumanoidRootPart")
if not Character or not Hum or not HumRp then return end
local function createDashEffect(direction)
local DashEfx = script.Efx.DashEfx:Clone()
DashEfx.Parent = HumRp
DashEfx.EmissionDirection = direction
DashEfx:Emit(50)
local SoundEfx = script.Efx.Dust:Clone()
SoundEfx.Parent = HumRp
SoundEfx:Play()
game.Debris:AddItem(SoundEfx, 1.4)
game.Debris:AddItem(DashEfx, 0.5)
end
if DashButton == "WButton" then
print("W")
Hum:LoadAnimation(script.Animation.WDash):Play()
createDashEffect("Back")
local bv = Instance.new("BodyVelocity")
bv.Name = "WDashVelocity"
bv.MaxForce = Vector3.new(50000, 0, 50000)
bv.Parent = HumRp
applyEasedVelocity(bv, HumRp.CFrame.LookVector, 105, 1.2)
-- Hitbox for damage
local hitbox = Instance.new("Part")
hitbox.Size = Vector3.new(4, 5, 4)
hitbox.Transparency = 0.5
hitbox.CanCollide = false
hitbox.Anchored = true
hitbox.CFrame = HumRp.CFrame * CFrame.new(0, 0, -5)
hitbox.Parent = workspace
local function onHit(otherPart)
local otherChar = otherPart.Parent
if otherChar and otherChar:FindFirstChild("Humanoid") and otherChar ~= Character then
local enemyPlayer = game.Players:GetPlayerFromCharacter(otherChar)
if enemyPlayer and enemyPlayer ~= Player then
otherChar.Humanoid.Health = math.max(0, otherChar.Humanoid.Health - 10)
if not otherChar:FindFirstChild("Stunned") then
local stunValue = Instance.new("BoolValue")
stunValue.Name = "Stunned"
stunValue.Parent = otherChar
task.delay(2, function() stunValue:Destroy() end)
end
end
end
end
local conn = hitbox.Touched:Connect(onHit)
task.wait(0.3)
conn:Disconnect()
hitbox:Destroy()
elseif DashButton == "SButton" then
print("S")
Hum:LoadAnimation(script.Animation.SDash):Play()
createDashEffect("Front")
local bv = Instance.new("BodyVelocity")
bv.Name = "SDashVelocity"
bv.MaxForce = Vector3.new(50000, 0, 50000)
bv.Parent = HumRp
applyEasedVelocity(bv, -HumRp.CFrame.LookVector, 105, 1.2)
elseif DashButton == "AButton" then
print("A")
Hum:LoadAnimation(script.Animation.ADash):Play()
createDashEffect("Right")
local bv = Instance.new("BodyVelocity")
bv.Name = "ADashVelocity"
bv.MaxForce = Vector3.new(50000, 0, 50000)
bv.Parent = HumRp
applyEasedVelocity(bv, -HumRp.CFrame.RightVector, 70, 0.6)
elseif DashButton == "DButton" then
print("D")
Hum:LoadAnimation(script.Animation.DDash):Play()
createDashEffect("Left")
local bv = Instance.new("BodyVelocity")
bv.Name = "DDashVelocity"
bv.MaxForce = Vector3.new(50000, 0, 50000)
bv.Parent = HumRp
applyEasedVelocity(bv, HumRp.CFrame.RightVector, 70, 0.6)
end
end)
** You are now Level 2! **