Unable to cast value to Object

I am making a weapon with a settings module script, and when trying to load the animations stored in the table inside the module called animationTracks, I get the error “Unable to cast value to Object”. What am I doing wrong? Here is the code that loads the animations:

local tool = script.Parent
local plr = tool.Parent.Parent
local char = plr.Character

local config = require(tool.Config)


local animTracks = {
	idle = char:FindFirstChild("Humanoid"):LoadAnimation(config.animationTracks["idleAnim"]);
	attack = char:FindFirstChild("Humanoid"):LoadAnimation(config.animationTracks["attackAnim"]);
	equip = char:FindFirstChild("Humanoid"):LoadAnimation(config.animationTracks["equipAnim"])
}

And here is the module script with the settings:

local Config = {}

Config.weaponStats = {
	knockback = 9000000,
	attackdelay = 0.35,
	attacktime = 0.3,
	cooldown = 1,
	damage = 999999
}

Config.animationTracks = {
	attackAnim = "http://www.roblox.com/Asset?ID=54611484",
	equipAnim = "rbxassetid://9234875887",
	idleAnim = "rbxassetid://9234882101"
}

return Config

If I am not mistaken, when loading animations on humanoid, you need to assign/refer the animation instance( that has your animation ID) , not the animation ID itself.

2 Likes

You are absolutely right, I am so stupid!

1 Like