I'm making a tower defense game and there's an error with my code and the output says "Config is not a valid member of Model "Archer"" while it is. It will change the model to the next upgrade but wont change the stat info on the GUI. Can someone help me? Thanks
function tower.Attack(newTower, player) local Config = newTower.Config local target = FindNearestTarget(newTower, Config.Range.Value) if target and target:FindFirstChild("Humanoid") and target.Humanoid.Health > 0 then local targetCFrame = CFrame.lookAt(newTower.HumanoidRootPart.Position, target.HumanoidRootPart.Position) newTower.HumanoidRootPart.BodyGyro.CFrame = targetCFrame animateTowerEvent:FireAllClients(newTower, "Attack") target.Humanoid:TakeDamage(Config.Damage.Value) if target.Humanoid.Health <= 0 then player.Gold.Value += target.Humanoid.MaxHealth end task.wait(Config.Cooldown.Value) end
(The error is on line 2)
Hi! Currently on my mothers computer, so i don't have roblox installed. However, this error could be caused based on the fact that you have named the variable Config. May not work but try changing it to:
local config = newTower.Config
Not 100% sure if thats why but its always worth a try! :)