I want to get information from this line about how much HP the opponent has in the script module.
local attributeName = game.ServerStorage.Enemies[enemyName]
What is the issue?
I wanted to get the opponent’s name from the module, but it doesn’t work and return nil…
Snippet from script:
for _,spawnPoint in pairs(spawnerlist) do
if game.Workspace.Level1.Respawns then
local respawnTime = spawnPoint:GetAttribute("RespawnTime")
local enemyName = spawnPoint:GetAttribute("EnemyName") -- returns the name of the opponent
local attributeName = game.ServerStorage.Enemies[enemyName]
local healthEnemy = nil
CombatSettings.Settings.Mobs[attributeName] = healthEnemy
print(healthEnemy)
spawnEnemy(spawnPoint, nil, respawnTime, attributeName)
end
end
attributeName is more than likely an instance based on how the path is defined. You should use enemyName instead of attributeName when you Index the dictionary.
This seems good. So I’ll ask about the previous block of code. Is the snippet of that code all of what is inside of the for loop? Do you reference CombatSettings.Settings.Mobs elsewhere as well?
Okey, I fixed the problem, it was related to the script not being able to detect the “Archer” class because there was a typo in ModulScript, which caused it to return nil because it couldn’t find such a name