This is for a Sandbox tycoon game where you palce items to get money. This a script where it gets a random item in the folder "game.ReplicatedStorage.items" and the item in PlayerData is increased by 1. I am getting the error in the question.
for _,Items in pairs(game.ReplicatedStorage.items:GetChildren()) do if Items.BuyAble.Value == false and Items.Tier.Value == 10 then if Items.RequiredEvolution.Value <= _G["PlayerData"][Player.Name]["Evolution"] then local RandomItem = math.random(#Items) _G["PlayerData"][Player.Name]["Inventory"][RandomItem] = _G["PlayerData"][Player.Name]["Inventory"][RandomItem]+1 end end