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

It's sending a error that says its a nil value?

Asked by 7 years ago
Edited 7 years ago

When i run it the local script send the error:

attempt to index local 'image' (a nil value) (line 10)

but image ins't a nil value please help me. I don't know what's wrong.

-local script(located in the starterGui)

game.ReplicatedStorage.Server.Start:FireServer()


game.ReplicatedStorage.Server.InventoryEvent.OnClientEvent:connect(function(name,rarity,image)
    local clone = script.Parent:WaitForChild("Frame").ScrollingFrame.Example:Clone()
    clone.Parent = script.Parent:WaitForChild("Frame").ScrollingFrame
    clone.Visible = true
    clone.Name = name.Name
    clone.name.Text = name.Name.." ("..rarity.Value..")"
    clone:WaitForChild("logo").Image = image.Value
end)

-script(just if there is something wrong here)(located in serverscriptservice)

local datastore = game:GetService('DataStoreService'):GetDataStore('Inventory')


function loaddata(plr)
    local key = 'privateplayerkey-//'..plr.UserId
    local inv = Instance.new('Folder',game.ServerStorage.InventoryContainer)
    local unsafeinv = Instance.new('Folder',plr)
    unsafeinv.Name = 'Inventory'
    inv.Name = plr.Name
    if datastore:GetAsync(key) then
        print("found something")
        for i = 1,#datastore:GetAsync(key) do
            print(datastore:GetAsync(key)[i][1])
            local item = Instance.new('Folder',game.ServerStorage.InventoryContainer:WaitForChild(plr.Name))
            item.Name = datastore:GetAsync(key)[i][1]
            local rare = Instance.new('StringValue',item)
            rare.Name = 'Rarity'
            rare.Value = datastore:GetAsync(key)[i][2]
            local image = Instance.new('StringValue',item)
            image.Name = 'Image'
            image.Value = datastore:GetAsync(key)[i][4]
            local Type = Instance.new('StringValue',item)
            Type.Name = 'Type'
            Type.Value = datastore:GetAsync(key)[i][3]
            --repeat wait() until plr:WaitForChild("PlayerGui").ScreenGui ~= nil
        --  local clone = plr:WaitForChild("PlayerGui").ScreenGui.Frame.ScrollingFrame:WaitForChild("Example"):Clone()
            --clone.Parent = plr:WaitForChild("PlayerGui").ScreenGui.Frame.ScrollingFrame
            --clone.Name = datastore:GetAsync(key)[i][1]
        --  clone.name.Text = datastore:GetAsync(key)[i][1].." ("..datastore:GetAsync(key)[i][3]..")"
        --  clone.ImageLabel.Image = datastore:GetAsync(key)[i][5]
        --  clone.Visible = true
            game.ReplicatedStorage.Server.InventoryEvent:FireClient(item.Name, rare.Value, image.Value)
        end
    else
        print("found nothing")
    end
    game.ServerStorage.InventoryContainer:WaitForChild(plr.Name).ChildAdded:connect(function(child)
        if child:IsA("Folder") then
            --  local clone = plr:WaitForChild("PlayerGui").ScreenGui.Frame.ScrollingFrame:WaitForChild("Example"):Clone()
            --  clone.Parent = plr:WaitForChild("PlayerGui").ScreenGui.Frame.ScrollingFrame
            --  clone.Name = child.Name
            --  clone.name.Text = child.Name.." ("..child.Rarity.Value..")"
            --  clone.ImageLabel.Image = child.Image.Value
            --  clone.Visible = true
            local clone = child:Clone()
            clone.Parent = unsafeinv
            clone.Name = child.Name
            game.ReplicatedStorage.Server.InventoryEvent:FireClient(clone,clone.Rarity,clone.Image)
        end         
    end)
    game.ServerStorage.InventoryContainer:WaitForChild(plr.Name).ChildRemoved:connect(function(child)
        if child:IsA("Folder") then
            if plr:WaitForChild("PlayerGui"):WaitForChild("ScreenGui").Frame.ScrollingFrame:FindFirstChild(child.Name) then
                --plr:WaitForChild("PlayerGui"):WaitForChild("ScreenGui").Frame.ScrollingFrame:WaitForChild(child.Name):Destroy()
                if unsafeinv:FindFirstChild(child.Name) then
                    game.ReplicatedStorage.Server.RemoveInventoryEvent:FireClient(unsafeinv:FindFirstChild(child.Name))
                    unsafeinv:FindFirstChild(child.Name):Destroy()
                end
            end
        end
    end)
end

function savedata(plr)
    local key = 'privateplayerkey-//'..plr.UserId
    local save = {}
    for i,v in pairs(game.ServerStorage.InventoryContainer:WaitForChild(plr.Name):GetChildren()) do
        if v:IsA('Folder') then
            --name, dublicates, rarity, image
            table.insert(save,{v.Name, v.Rarity.Value, v.Type.Value, v.Image.Value})
            print("saved"..v.Name)
        end
    end
    datastore:SetAsync(key,save)
    game.ServerStorage.InventoryContainer:WaitForChild(plr.Name):Destroy()
end


game.ReplicatedStorage.Server.Start.OnServerEvent:connect(loaddata)
game.Players.PlayerRemoving:connect(savedata)

btw these scripts together make a inventory save system.(not done)

0
which script is the error in Viking359 161 — 7y
0
The local script frederikhome 44 — 7y
0
"but it is not a nil value" uses crtl + f, finds no where it defines image hiimgoodpack 2009 — 7y

Answer this question