#Dash Animation Not Working

12 messages · Page 1 of 1 (latest)

runic thorn
#

The Dash is not working here, plus it only teleports not dash before it did not work

local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local Humanoid = LocalPlayer.Character:WaitForChild("Humanoid")

local dashSpeed = 50
local dashDuration = 0.5

local character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")

local dashAnimation = Instance.new("Animation")
dashAnimation.AnimationId = "rbxassetid://18271810196"
local dashAnimationTrack = Humanoid:LoadAnimation(dashAnimation)

local function dash(direction)
local currentCFrame = humanoidRootPart.CFrame
local dashDistance = direction * dashSpeed
local targetCFrame = currentCFrame + dashDistance
humanoidRootPart.CFrame = targetCFrame
dashAnimationTrack:Play()
task.wait(dashDuration)
end

local function onInputBegan(input, gameProcessed)
if gameProcessed then return end

if input.KeyCode == Enum.KeyCode.Q then 
    local characterDirection = humanoidRootPart.CFrame.LookVector
    dash(characterDirection)
end

end

UserInputService.InputBegan:Connect(onInputBegan)

oak gust
#

Are you sure it teleports

#

The way it's scripted, it might just be moving really fast

#

And when you dash multiple times, is the distance and speed constant?

oak gust
#

any errors?

#

it doesn't look like there's anything wrong

runic thorn
#

there are errors

#

@oak gust 20:47:41.044 Players.MechaMechaStrikers.PlayerScripts.DashScript:4: attempt to index nil with 'WaitForChild' - Client - DashScript:4

oak gust
#

oh

#

LocalPlayer is a keyword

#

You can't use it as a variable name