attempt to index nil with 'Gold'?
I'm making a tds game and i experienced an error.
I tried using :WaitForChild() but it gave me the same exact error.
01 | function towerModule.attackMob(newTower, player) |
02 | local config = newTower.Config |
03 | local target = findNearestTarget(newTower, config.Range.Value) |
04 | if target and target:FindFirstChild( 'Zombie' ) and target.Zombie.Health > 0 then |
05 | local targetCFrame = CFrame.lookAt(newTower.HumanoidRootPart.Position, target.HumanoidRootPart.Position) |
06 | newTower.HumanoidRootPart.BodyGyro.CFrame = targetCFrame |
08 | target.Zombie:TakeDamage(config.Damage.Value) |
09 | if target.Zombie.Health < = 0 then |
10 | player.Gold.Value + = target.Zombie.MaxHealth |
12 | task.wait(config.Cooldown.Value) |
16 | towerModule.attackMob(newTower) |
I believe the code block is the reason why it's erroring.
But, here is the error that i am experiencing:
14:56:44.149 ServerScriptService../main../tower:32: attempt to index nil with 'Gold' - Server - ./tower:32
14:56:44.149 Stack Begin - Studio
14:56:44.149 Script 'ServerScriptService../main../tower', Line 32 - function attackMob - Studio - ./tower:32
14:56:44.149 ? Script 'ServerScriptService../main../tower', Line 38 - function attackMob (x49) - Studio - ./tower:38
14:56:44.152 Stack End
I would be very happy for solutions.