Basically making my own FPS framework, and then suddenly this error occurs:
- Attempt to index nil with 'Idle'
When the parent of Idle isn’t even nil. Here’s the module:
local root = script.Parent;
local data = {
animations = {
viewmodel = {
idle = root.animations.view.idle;
shoot = root.animations.view.shoot;
reload = root.animations.view.reload;
equip = root.animations.view.equip;
};
player = {
idle = root.animations.out.idle;
hipfire = root.animations.out.hipfire;
aimfire = root.animations.out.aimfire;
reload = root.animations.out.reload;
};
};
firing = {
rpm = 857;
magCapacity = 30;
}
}
return data;
And here’s how I access it:
-- inserting into table
remotes:WaitForChild("new").OnServerInvoke = function(player)
if not player.Character then return; end
players[player.UserId] = {};
local weaponTable = players[player.UserId];
weaponTable.magData = {};
weaponTable.weapons = {};
for index, weaponName in pairs(defaultWeapons) do
local weapon = weapons:FindFirstChild(weaponName):Clone();
local weaponSettings = require(weapon.settings);
print(weapon)
print(weaponSettings.animations.player.idle);
print(weaponSettings.animations.viewmodel.idle);
weaponTable.weapons[weaponName] = { weapon = weapon; settings = weaponSettings; };
console.log(weaponTable.weapons[weaponName].settings.animations.player.idle);
weaponTable.magData[index] = { current = weaponSettings.firing.magCapacity;
spare = weaponSettings.firing.magCapacity * magazineCount};
weapon.Parent = player.Character;
weapon.Handle.backweld.Part0 = player.Character.Torso;
end
return defaultWeapons, weaponTable.magData;
end
-- getting it
remotes:WaitForChild("equip").OnServerInvoke = function(player, wepName)
if players[player.UserId].currentWeapon then return; end
-- if not players[player.UserId].weapons[wepName] then return; end
if not player.Character then return; end
local weaponTable = players[player.UserId];
weaponTable.currentWeapon = weaponTable.weapons[wepName];
player.gun.Value = weaponTable.currentWeapon.weapon;
weaponTable.currentWeapon.Parent = player.Character;
weaponTable.currentWeapon.weapon.Handle.backweld.Part0 = nil;
weaponTable.currentWeapon.weapon.Handle.weaponHold.Part0 = player.Character["Right Arm"];
weaponTable.loadedAnimations.idle = player.Character.Humanoid:LoadAnimation(weaponTable.currentWeapon.settings.animations.player.idle);
--weaponTable.currentWeapon.weapon.settings.animations.player.idle
weaponTable.loadedAnimations.idle:Play(0.4);
return true;
end
why is this happening?
