"Attempt to index nil with 'stat'" How to fix that ? (Roblox)

43 views Asked by At

PROBLEM:

Hi The output says:

Players.username.PlayerGui.GameGui.GameController:63: attempt to index nil with 'Stats'

This is my code:

local maxTowers = towerToSpawn.Stats.MaxPlaced.Value

local PlacedTowers = towerToSpawn.Stats.Placed.Value

What the problem ?

CONTEXT:

I make a tower defense and I want to restrict the number of each type of tower that can be placed.

ps :

local towerToSpawn = ReplicatedStorage:WaitForChild("Towers"):FindFirstChild(name):Clone()

enter image description here

0

There are 0 answers