Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to fix the error where it cant find the a thing in a model but its in the model ?

Asked by 2 years ago
Edited 2 years ago

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)

1 answer

Log in to vote
0
Answered by 2 years ago

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! :)

Ad

Answer this question