I’m trying to make a dash ability script but when I run try to test the game it says in the output: Workspace.ThisBot19.DashScript:122: attempt to index nil with ‘CFrame’
The error is on line 122
This is the script, it is a local script in startercharacterscripts
local RS = game:GetService("ReplicatedStorage")
local VfxFolder = RS:WaitForChild("VfxFolder")
local DashClone = VfxFolder:WaitForChild("DashClone")
local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local Player = game.Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()
local Hum = Char:WaitForChild("Humanoid")
local HRP = Char:WaitForChild("HumanoidRootPart")
local WKeyDown = false
local AKeyDown = false
local SKeyDown = false
local DKeyDown = false
local DashDeb = false
local DashTime = 0.3
local AnimationFolder = script:WaitForChild("AnimationFolder")
local ForwardDashAnime = Hum:LoadAnimation(AnimationFolder:WaitForChild("ForwardDash"))
local BackDashAnime = Hum:LoadAnimation(AnimationFolder:WaitForChild("BackDash"))
local LeftDashAnime = Hum:LoadAnimation(AnimationFolder:WaitForChild("LeftDash"))
local RightDashAnime = Hum:LoadAnimation(AnimationFolder:WaitForChild("RightDash"))
local Event = script:WaitForChild("Event")
UIS.InputBegan:Connect(function(Key,IsTyping)
if IsTyping then return end
if Key.KeyCode == Enum.KeyCode.Q then
if DashDeb == false and Char:FindFirstChild("Deb") == nil then
DashDeb = true
delay(DashTime + 0.7,function()
DashDeb = false
end)
if WKeyDown then
coroutine.wrap(function()
DashEffect()
end)()
local Tween = TweenService:Create(HRP,TweenInfo.new(DashTime,Enum.EasingStyle.Linear,Enum.EasingDirection.Out),{Velocity = HRP.CFrame.LookVector * 70})
Tween:Play()
ForwardDashAnime:Play()
Event:FireServer("Dash")
delay(DashTime + 0.1,function()
ForwardDashAnime:Stop()
end)
elseif AKeyDown then
coroutine.wrap(function()
DashEffect()
end)()
local Tween = TweenService:Create(HRP,TweenInfo.new(DashTime,Enum.EasingStyle.Linear,Enum.EasingDirection.Out),{Velocity = HRP.CFrame.RightVector * -70})
Tween:Play()
LeftDashAnime:Play()
Event:FireServer("Dash")
delay(DashTime + 0.1,function()
LeftDashAnime:Stop()
end)
elseif SKeyDown then
coroutine.wrap(function()
DashEffect()
end)()
local Tween = TweenService:Create(HRP,TweenInfo.new(DashTime,Enum.EasingStyle.Linear,Enum.EasingDirection.Out),{Velocity = HRP.CFrame.LookVector * -70})
Tween:Play()
BackDashAnime:Play()
Event:FireServer("Dash")
delay(DashTime + 0.1,function()
BackDashAnime:Stop()
end)
elseif DKeyDown then
coroutine.wrap(function()
DashEffect()
end)()
local Tween = TweenService:Create(HRP,TweenInfo.new(DashTime,Enum.EasingStyle.Linear,Enum.EasingDirection.Out),{Velocity = HRP.CFrame.RightVector * 70})
Tween:Play()
RightDashAnime:Play()
Event:FireServer("Dash")
delay(DashTime + 0.1,function()
RightDashAnime:Stop()
end)
end
end
end
end)
RunService.RenderStepped:Connect(function()
if UIS:IsKeyDown(Enum.KeyCode.W) then
WKeyDown = true
else
WKeyDown = false
end
if UIS:IsKeyDown(Enum.KeyCode.A) then
AKeyDown = true
else
AKeyDown = false
end
if UIS:IsKeyDown(Enum.KeyCode.S) then
SKeyDown = true
else
SKeyDown = false
end
if UIS:IsKeyDown(Enum.KeyCode.D) then
DKeyDown = true
else
DKeyDown = false
end
end)
function DashEffect()
for i = 1,7 do
local Clone = DashClone:Clone()
Clone:SetPrimaryPartCFrame(HRP.CFrame)
Clone.Parent = workspace
game.Debris:AddItem(Clone,0.5)
spawn(function()
for i,v in pairs(Clone:GetChildren()) do
spawn(function()
if v:IsA("MeshPart") or v:IsA("Part") then
v.CFrame = Char:FindFirstChild(v.Name).CFrame
for i = 0.25,1,0.1 do
v.Transparency = i
v.Reflectance = i
wait()
end
Clone:Destroy()
end
end)
end
end)
wait(0.05)
end
end
If it will help the key binds for the dash are: Q + W, Q + A, Q + D, Q + S different key binds for each direction.