Ad
Log in to vote
0

483 / 550 Errors; How to fix them? (Local Value is of type: ...)

Asked by 11 days ago

I have a problem with this code. I am getting two different error messages. The first is a: 483 Error And the second is:

550 - ServerScriptService.MaterialScript:68: attempt to index local 'il' (a number value) How do I fix this error, because I need it to be an integer for serialization to put into a Data Store. Any help would be greatly appreciated.

Thanks in advance, Jerry

local DSS = game:GetService("DataStoreService")
local MaterialsDS = DSS:GetDataStore("GameDB", "MaterialsInfo")
local UpdateDS = DSS:GetDataStore("GameDB", "UpdateInfo")
UpdateDS:SetAsync("UpdateValue", 100)
--[[
    Materials have the following Properties:

    Material#1
        - Name: String
        - Description: String
        - Icon: path (Str?)
        - Price: Integer (Lowest Currency)
        - Rarity: Integer
            Converted from Number into a word:
                1   -   "Common"
                2   -   "Uncommon"
                3   -   "Rare"
                4   -   "Ultra Rare"
                5   -   "Legendary"
                6   -   "Godly"
                7   -   "HACKS" ( Admin Only )
        - Recipe: { Tuple (Id, Amt) (or {} if non existent) ... }

--]]

MaterialsDS.Changed:connect(function()
    print("CHANGED")
end)

game.Loaded:Connect(function()
    print("Game Loaded Successfully!")
end)


local iconsPath = workspace.Assets.Icons
local updatePath = 100
local MaterialsList = {
    ["0"] = {
        ["Name"] = "Wood",
        ["Description"] = "Just some basic wood.",
        ["Icon"] = iconsPath.StandInTexture,
        ["Price"] = 1,
        ["Rarity"] = 1,
        ["Recipe"] = {},
        ["Id"] = 0

    },
    ["1"] = {
        ["Name"] = "Stone",
        ["Description"] = "Stone from 7 feet under.",
        ["Icon"] = iconsPath.StandInTexture,
        ["Price"] = 2,
        ["Rarity"] = 1,
        ["Recipe"] = {},
        ["Id"] = 1

    },

    ["Length"] = 1
}

local ServerUpdatePath = MaterialsDS:GetAsync("UpdateValue")

if workspace.IsServerLoaded.Value == false then
    print(MaterialsList)
    print("Elements in Dictionary: ".. MaterialsList.Length + 1)
    for il=0, MaterialsList.Length, 1 do
        local data = MaterialsDS:GetAsync(il.ToInt()) or nil
        if data == nil or updatePath > ServerUpdatePath then

            -- Doesn't Exist in DB, therefore, the server must add it, or if the two versions differ, the client server takes priority,
            -- (and subsequently triggers an event that triggers across all servers that run a function to find the discrepency and apply the new model) (end)
            --  (to their code)(Possibly Automatic Material + Item Updates?!??!!?)
            local val = il.ToInt()
            print(typeof(il))
            -- ERROR: CANNOT STORE DICTIONARY IN DATA STORE. DATA STORES CAN ONLY ACCEPT VALID UTF-8 CHARACTERS
            MaterialsDS:SetAsync(val, MaterialsList[""..val])

            print(MaterialsList[""..val].Name.. "did not exist or did not match current standards.")



        elseif data ~= nil or updatePath < ServerUpdatePath then
            -- If it exists, but our update model is inferior to the server's, then we should update our model(end)
            MaterialsList[""..val] = data

        end



        end


    if updatePath > ServerUpdatePath then
        UpdateDS:SetAsync("UpdateValue", updatePath)
        print("Successfully Updated Server Model")

    elseif updatePath < ServerUpdatePath then
        updatePath = ServerUpdatePath
        print("Successfully Updated Client Model")

    else
        print("Server and Client Models are Compatible!")
    end

    print("Done!")
    workspace.IsServerLoaded.Value = true
end

0
BTW: "Length" of the MaterialsList starts from Zero. JerryYoutube 6 — 11d
0
Is this all in a LocalScript? MexheCo 29 — 11d
0
Its just a script because it has to interface with the DataStoreService JerryYoutube 6 — 10d

Answer this question