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

error 'Attempt to get length of Items (a userdata value)'. Checked wiki but no?

Asked by
oilkas 364 Moderation Voter
6 years ago

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

Answer this question