@br_cks its always causing the same issue this is the script, its always like the video
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local DustTrail = game.ReplicatedStorage:WaitForChild("VFX"):WaitForChild("DashDust"):WaitForChild("Attachment")
local DashBoost = game.ReplicatedStorage.VFX:WaitForChild("Ring")
local humanoid = character:WaitForChild("Humanoid")
character:WaitForChild("Torso")
local dashConfig = {
forward = {speed = 100, time = 1},
backward = {speed = 150, time = 0.5},
left = {speed = 100, time = 0.5},
right = {speed = 100, time = 0.5}
}
local cooldown = 2
local lastDashTimes = {forward = 0, backward = 0, left = 0, right = 0}
local isDashing = false
local dashDirection = nil
local animations = {
forward = humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Dashing.DashStart),
backward = humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Dashing.BackDash),
left = humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Dashing.LeftDash),
right = humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Dashing.RightDash),
hit = humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Dashing.DashHit)
}
local currentAnim = nil
local function playAnimation(directionKey)
if currentAnim then
currentAnim:Stop()
end
currentAnim = animations[directionKey]
if currentAnim then
currentAnim:Play()
end
end
local function getDirectionVector()
if isDashing then
return Vector3.new(), nil
end
if UserInputService:IsKeyDown(Enum.KeyCode.W) then
return character.PrimaryPart.CFrame.LookVector, "forward"
elseif UserInputService:IsKeyDown(Enum.KeyCode.A) then
return -character.PrimaryPart.CFrame.RightVector, "left"
elseif UserInputService:IsKeyDown(Enum.KeyCode.S) then
return -character.PrimaryPart.CFrame.LookVector, "backward"
elseif UserInputService:IsKeyDown(Enum.KeyCode.D) then
return character.PrimaryPart.CFrame.RightVector, "right"
end
return Vector3.new(), nil
end
game:GetService("Workspace")
local TweenService = game:GetService("TweenService")
local Debris = game:GetService("Debris")
local function createRock(spawnPosition, heightOffset)
local raycastParams = RaycastParams.new()
raycastParams.IgnoreWater = true
raycastParams.FilterDescendantsInstances = {character}
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
local rayOrigin = spawnPosition + Vector3.new(0, 50, 0)
local rayDirection = Vector3.new(0, -100, 0)
local raycastResult = game.Workspace:Raycast(rayOrigin, rayDirection, raycastParams)
if raycastResult then
local groundMaterial = raycastResult.Instance.Material
local groundColor = raycastResult.Instance.Color
local rock = Instance.new("Part")
rock.Shape = Enum.PartType.Block
rock.Material = groundMaterial
rock.Color = groundColor
rock.Size = Vector3.new(0.2, 0.2, 0.2)
rock.Position = raycastResult.Position + Vector3.new(0, heightOffset - 0.1, 0) + Vector3.new(0, rock.Size.Y / 2, 0)
rock.Anchored = true
rock.Parent = game.Workspace
local randomRotation = Vector3.new(math.random() * 360, math.random() * 360, math.random() * 360)
rock.Orientation = randomRotation
local growTween = TweenService:Create(rock, TweenInfo.new(0.3), {Size = Vector3.new(1, 1, 1), Position = raycastResult.Position + Vector3.new(0, heightOffset + 0.5, 0)})
growTween:Play()
coroutine.wrap(function()
wait(4.5)
local dropTween = TweenService:Create(rock, TweenInfo.new(0.5), {Position = rock.Position - Vector3.new(0, 3, 0)})
dropTween:Play()
dropTween.Completed:Wait()
rock:Destroy()
end)()
end
end
local function dash(initialDirection, directionKey)
if isDashing or character:GetAttribute("IsPunching") then return end
character:SetAttribute("IsDashing", true)
local currentTick = tick()
local dashCooldown = lastDashTimes[directionKey] + cooldown
local currentTick = tick()
local dashCooldown = lastDashTimes[directionKey] + cooldown
if currentTick < dashCooldown then
character:SetAttribute("IsDashing", false)
return
end
isDashing = true
dashDirection = directionKey
lastDashTimes[directionKey] = currentTick
local oldWalkSpeed = character.Humanoid.WalkSpeed
character.Humanoid.WalkSpeed = 0
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.MaxForce = Vector3.new(50000, 0, 50000)
bodyVelocity.P = 12500
bodyVelocity.Parent = character.PrimaryPart
local startingPosition = character.PrimaryPart.Position
local estimatedFinal = character.PrimaryPart.CFrame.Position + (character.PrimaryPart.CFrame.LookVector * (bodyVelocity.MaxForce / 850))
local target
local endPosition
local boostEffect = DashBoost:Clone()
boostEffect.Parent = workspace
boostEffect.CFrame = character.PrimaryPart.CFrame * CFrame.new(0, 0, -2)
boostEffect.Massless = true
boostEffect.Anchored = true
local scaleTween = TweenService:Create(boostEffect, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {Size = boostEffect.Size * 5})
local fadeTween = TweenService:Create(boostEffect, TweenInfo.new(0.2, Enum.EasingStyle.Linear, Enum.EasingDirection.In), {Transparency = 1})
scaleTween:Play()
scaleTween.Completed:Connect(function()
fadeTween:Play()
fadeTween.Completed:Connect(function()
boostEffect:Destroy()
end)
end)
for i, v in pairs(game.Workspace:GetDescendants()) do
if v:FindFirstChild("Humanoid") and v.Name ~= player.Name and v.PrimaryPart then
local maxX = v.PrimaryPart.Position.X + 3
local minX = v.PrimaryPart.Position.X - 3
local maxZ = v.PrimaryPart.Position.Z + 3
local minZ = v.PrimaryPart.Position.Z - 3
local smallestX = if startingPosition.X > estimatedFinal.X then estimatedFinal.X else startingPosition.X
local largestX = if startingPosition.X > estimatedFinal.X then startingPosition.X else estimatedFinal.X
local smallestZ = if startingPosition.Z > estimatedFinal.Z then estimatedFinal.Z else startingPosition.Z
local largestZ = if startingPosition.Z > estimatedFinal.Z then startingPosition.Z else estimatedFinal.Z
if (math.clamp(minX, smallestX, largestX) == minX and math.clamp(minZ, smallestZ, largestZ) == minZ ) then
target = v
break
elseif (math.clamp(maxX, smallestX, largestX) == maxX and math.clamp(minZ, smallestZ, largestZ) == minZ ) then
target = v
break
elseif (math.clamp(minX, smallestX, largestX) == minX and math.clamp(maxZ, smallestZ, largestZ) == maxZ ) then
target = v
break
elseif (math.clamp(maxX, smallestX, largestX) == maxX and math.clamp(maxZ, smallestZ, largestZ) == maxZ ) then
target = v
break
end
end
end
local timeMultiplier = 1
if target and dashDirection == "forward" then
timeMultiplier = ((startingPosition - target.HumanoidRootPart.Position).Magnitude / (startingPosition - estimatedFinal).Magnitude) * 0.9
player.Character.Torso.CFrame = CFrame.lookAt(player.Character.Torso.Position, target.PrimaryPart.Position)
end
local dashInfo = dashConfig[directionKey]
local dashStartTime = tick()
local dashEndTime = dashStartTime + (dashInfo.time * timeMultiplier)
local decelerationStartFraction = 0.2
local decelerationStartTime = dashStartTime + (dashInfo.time * timeMultiplier) * decelerationStartFraction
local initialVelocityMagnitude = dashInfo.speed * 1.5
local leftLeg = character:FindFirstChild("Left Leg")
local rightLeg = character:FindFirstChild("Right Leg")
local leftDustClone = DustTrail:Clone()
leftDustClone.Parent = leftLeg
leftDustClone.CFrame = CFrame.new(0, 0, 0) * CFrame.Angles(math.rad(-90), 0, 0)
local rightDustClone = DustTrail:Clone()
rightDustClone.Parent = rightLeg
rightDustClone.CFrame = CFrame.new(0, 0, 0) * CFrame.Angles(math.rad(-90), 0, 0)
coroutine.wrap(function()
local rockSpawnRate = 0.05
local nextRockSpawnTime = tick()
local hitAnimationPlayed = false
local spawnEndTime = dashEndTime - 0.3
while tick() < spawnEndTime do
if tick() >= nextRockSpawnTime then
local rightVector = character.PrimaryPart.CFrame.RightVector
local leftSpawnPosition = character.PrimaryPart.Position - rightVector * 3
local rightSpawnPosition = character.PrimaryPart.Position + rightVector * 3
local function adjustToGroundLevel(position)
local raycastParams = RaycastParams.new()
raycastParams.IgnoreWater = true
raycastParams.FilterDescendantsInstances = {character}
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
local rayOrigin = position + Vector3.new(0, 50, 0)
local rayDirection = Vector3.new(0, -100, 0)
local raycastResult = game.Workspace:Raycast(rayOrigin, rayDirection, raycastParams)
if raycastResult then
return raycastResult.Position
else
return position
end
end
leftSpawnPosition = adjustToGroundLevel(leftSpawnPosition)
rightSpawnPosition = adjustToGroundLevel(rightSpawnPosition)
createRock(leftSpawnPosition, -0.5)
createRock(rightSpawnPosition, -0.5)
nextRockSpawnTime = tick() + rockSpawnRate
end
local currentTime = tick()
local currentDirectionVector = initialDirection
if dashDirection == "forward" then
if UserInputService:IsKeyDown(Enum.KeyCode.W) then
currentDirectionVector = character.PrimaryPart.CFrame.LookVector
end
elseif dashDirection == "left" then
if UserInputService:IsKeyDown(Enum.KeyCode.A) then
currentDirectionVector = -character.PrimaryPart.CFrame.RightVector
end
elseif dashDirection == "backward" then
if UserInputService:IsKeyDown(Enum.KeyCode.S) then
currentDirectionVector = -character.PrimaryPart.CFrame.LookVector
end
elseif dashDirection == "right" then
if UserInputService:IsKeyDown(Enum.KeyCode.D) then
currentDirectionVector = character.PrimaryPart.CFrame.RightVector
end
end
local smoothFactor
if currentTime < decelerationStartTime then
smoothFactor = 1
else
local decelerationElapsed = currentTime - decelerationStartTime
local decelerationDuration = dashEndTime - decelerationStartTime
local decelerationFractionComplete = decelerationElapsed / decelerationDuration
smoothFactor = 1 - (decelerationFractionComplete ^ (1/3))
end
local currentVelocity = currentDirectionVector.unit * initialVelocityMagnitude * smoothFactor
bodyVelocity.Velocity = currentVelocity
RunService.Heartbeat:Wait()
end
if not hitAnimationPlayed then
if currentAnim then
currentAnim:Stop(0.1)
end
if dashDirection == 'forward' then
animations.hit:Play(0.1)
local BridgeNet = require(game.ReplicatedStorage.Modules.BridgeNet2)
local Bridge = BridgeNet.ClientBridge("DashHitEvent")
Bridge:Fire(player.UserId)
if leftDustClone then
print("done")
leftDustClone:Destroy()
end
if rightDustClone then
rightDustClone:Destroy()
end
end
hitAnimationPlayed = true
end
character:SetAttribute("IsDashing", false)
bodyVelocity:Destroy()
character.Humanoid.WalkSpeed = oldWalkSpeed
isDashing = false
dashDirection = nil
end)()
playAnimation(directionKey)
end
UserInputService.InputBegan:Connect(function(input, isProcessed)
if isProcessed or input.KeyCode ~= Enum.KeyCode.Q then return end
local directionVector, directionKey = getDirectionVector()
if directionVector and directionKey then
dash(directionVector, directionKey)
end
end)```