I was creating animations for my sword game and weirdly I loaded an animation and got this error.
THE ERROR IS ON THE LINE WHERE IT SAYS: SwordWalkTrack = Animator:LoadAnimation(SwordWalkAnimation)
--!nonstrict
--// Variables
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local CollectionService = game:GetService("CollectionService")
local Player = Players.LocalPlayer or Players.PlayerAdded:Wait()
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid: Humanoid = Character.Humanoid
local Animator: Animator = Character.Humanoid.Animator
--// Movement Variables
local DashDebounce = false
local DashVelocity = 14000
local DashDuration = .2
local WDown = false
local ADown = false
local SDown = false
local DDown = false
--// Animations
local Animations = {
["dash"] = "rbxassetid://15779249175",
["swordidle"] = "rbxassetid://15779789629",
["swordwalk"] = "rbxassetid://15780061008"
}
local DashAnimation = Instance.new("Animation")
DashAnimation.AnimationId = Animations["dash"]
local SwordIdleAnimation = Instance.new("Animation")
SwordIdleAnimation.AnimationId = Animations["swordidle"]
local SwordWalkAnimation = Instance.new("Animation")
SwordWalkAnimation.AnimationId = Animations["swordwalk"]
local DashTrack = Animator:LoadAnimation(script.dash)
DashTrack.Priority = Enum.AnimationPriority.Action
local SwordIdleTrack = Animator:LoadAnimation(SwordIdleAnimation)
SwordIdleTrack.Priority = Enum.AnimationPriority.Idle
local SwordWalkTrack = Animator:LoadAnimation(SwordWalkAnimation)
SwordWalkTrack.Priority = Enum.AnimationPriority.Movement
SwordWalkTrack.Looped = true--]]
--// Keycodes
local Keycodes = {
["DashKeycode"] = Enum.KeyCode.F
}
--// Events
RunService.RenderStepped:Connect(function()
SwordIdleTrack:Stop()
local ToolEquipped = Character:FindFirstChildOfClass("Tool")
if ToolEquipped then
local IsKatana = ToolEquipped:HasTag("Katana")
if Humanoid.MoveDirection:Dot(Humanoid.MoveDirection) == 0 and IsKatana then
SwordIdleTrack:Play()
--SwordWalkTrack:Stop()
else
--SwordWalkTrack:Play()
end
end
if UserInputService:IsKeyDown(Enum.KeyCode.W) then
WDown = true
else
WDown = false
end
if UserInputService:IsKeyDown(Enum.KeyCode.A) then
ADown = true
else
ADown = false
end
if UserInputService:IsKeyDown(Enum.KeyCode.S) then
SDown = true
else
SDown = false
end
if UserInputService:IsKeyDown(Enum.KeyCode.D) then
DDown = true
else
DDown = false
end
end)
--// Functions
local Functions = {}
Functions["Dash"] = function(character)
do
if not DashDebounce then
DashDebounce = true
local StartTime = tick()
local HumanoidRootPart: Part = character:FindFirstChild("HumanoidRootPart")
local Humanoid: Humanoid = character:FindFirstChild("Humanoid")
local DashDirection
local MoveDirection = Humanoid.MoveDirection
local LookVector = HumanoidRootPart.CFrame.LookVector
local NegVelocity = -DashVelocity
if MoveDirection == Vector3.new(0, 0, 0) then
DashDirection = HumanoidRootPart.CFrame * CFrame.new(LookVector.X, 0, LookVector.Z)
else
DashDirection = HumanoidRootPart.CFrame * CFrame.new(MoveDirection.X, 0, MoveDirection.Z)
end
local BodyGyro = Instance.new("BodyGyro")
BodyGyro.Parent = HumanoidRootPart
BodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
BodyGyro.D = 0
BodyGyro.P = 1
BodyGyro.CFrame = CFrame.lookAt(HumanoidRootPart.Position, Vector3.new(DashDirection))
local Attachment = Instance.new("Attachment")
Attachment.Parent = HumanoidRootPart
local VectorForce = Instance.new("VectorForce")
VectorForce.Parent = HumanoidRootPart
VectorForce.Attachment0 = Attachment
VectorForce.Force = Vector3.new(0, 0, NegVelocity)
Humanoid.AutoRotate = false
DashTrack:Play()
task.wait(DashDuration)
Humanoid.AutoRotate = true
VectorForce:Destroy()
BodyGyro:Destroy()
DashTrack:Stop()
local EndTime = tick()
task.wait(1)
DashDebounce = false
end
end
end
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if not gameProcessed then
if input.KeyCode == Keycodes["DashKeycode"] then
Functions["Dash"](Character)
end
end
end)