I’m working on a script that will let the character dash a direction when they press E.
When I press E to dash I get the error in the title “LoadAnimation is not a valid member of Model Workspace.KayneWestReal” and am directed to the line that goes
“local playanim = player.Character:LoadAnimation(anim)”
I assumed it was a simple issue originally but I have been working on this for a few hours now with no success, anyone have any ideas?
My code:
dashremote.OnServerEvent:Connect(function(player, dir)
if not candash then return end
candash = false
local char = player.Character
local Humanoid = char:WaitForChild("Humanoid")
local root = char:FindFirstChild("HumanoidRootPart")
local bv = Instance.new("BodyVelocity", root)
bv.MaxForce = Vector3.new(1,1,1) * 30000
bv.Velocity = root.CFrame * CFrame.Angles(0,math.rad(dir), 0).lookVector * 120
game.Debris:AddItem(bv, dashDuration)
local anim = script.DashForward
if dir == 180 then
anim = script.DashBackward
elseif dir == 90 then
anim = script.DashLeft
elseif dir == -90 then
anim = script.DashRight
end
local playanim = player.Character:LoadAnimation(anim)
playanim:Play()
wait(dashDuration)
playanim:Stop()
wait(dashCooldown - dashDuration)
candash = true
end)