of     1   

Tynexx
#139813357Wednesday, July 09, 2014 11:56 PM GMT

ServerScriptService.RPGMain.InventorySave:36: attempt to index a nil value That's the error. script: DS = game:GetService("DataStoreService"):GetDataStore("Inventory") game.Players.PlayerRemoving:connect(function(plr) DS:UpdateAsync(plr.userId, function() tab = {} cur = {} for i,v in pairs(plr.Weapons:GetChildren()) do table.insert(tab, v.Name) end for i,v in pairs(plr.CurrentArmor:GetChildren()) do table.insert(cur, v.Name) end return tab and cur --only return the table once all the values are inserted end) end) game.Players.PlayerAdded:connect(function(plr) --check to see if they have weapons or not if not (DS:GetAsync(plr.userId)) then DS:SetAsync(plr.userId, {}) end if not (DS:GetAsync(plr.userId.."Cur")) then DS:SetAsync(plr.userId.."Cur", {}) end local invDS = DS:GetAsync(plr.userId) --set the table to a variable local curDS = DS:GetAsync(plr.userId.."Cur") local inv = Instance.new("Model", plr) inv.Name = "Bag" local curr = Instance.new("Model", plr) curr.Name = "CurrentArmor" for i,v in pairs(invDS) do game.Lighting:FindFirstChild(v):Clone().Parent = inv end for i,v in pairs(curDS) do plr.Bag:FindFirstChild(v):Clone().Parent = curr end plr.Bag.ChildAdded:connect(function(item) DS:UpdateAsync(plr.userId, function() tab ={} table.insert(tab, item.Name) return tab end) end ) plr.CurrentArmor.ChildAdded:connect(function(item) DS:UpdateAsync(plr.userId.."Cur", function() cur ={} table.insert(cur, item.Name) return cur end) end ) plr.Bag.ChildRemoved:connect(function(item) DS:UpdateAsync(plr.userId, function() tab ={} for i,v in pairs(tab) do if v==item.Name then table.remove(tab, i) return tab end end end) end) plr.CurrentArmor.ChildRemoved:connect(function(item) DS:UpdateAsync(plr.userId, function() cur ={} for i,v in pairs(cur) do if v.Name==item.Name then table.remove(cur, i) return cur end end end) end) end) game.Players.PlayerAdded:connect(function(p) p.CharacterAdded:connect(function(c) repeat wait() until p:FindFirstChild("Bag") local bag = p.Bag for i,v in pairs(bag:GetChildren()) do v.Parent = nil wait(1) v.Parent = bag end end) end) game.Players.PlayerAdded:connect(function(p) p.CharacterAdded:connect(function(c) repeat wait() until p:FindFirstChild("CurrentArmor") local bag = p.Bag for i,v in pairs(bag:GetChildren()) do v.Parent = nil wait(1) v.Parent = bag end end) end)
Tynexx
#139814123Thursday, July 10, 2014 12:04 AM GMT

Please help.
swimguy777
#139814260Thursday, July 10, 2014 12:05 AM GMT

What's on line 36? -[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::]
Tynexx
#139814741Thursday, July 10, 2014 12:10 AM GMT

for i,v in pairs(curDS) do plr.Bag:FindFirstChild(v):Clone().Parent = curr end
swimguy777
#139814842Thursday, July 10, 2014 12:11 AM GMT

Are you sure that everything in that line actually exists? -[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::]
Tynexx
#139814889Thursday, July 10, 2014 12:11 AM GMT

No, sometimes it may not exist why?
swimguy777
#139815019Thursday, July 10, 2014 12:12 AM GMT

You're getting the error when something in that line doesn't exist. -[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::]
Tynexx
#139815257Thursday, July 10, 2014 12:15 AM GMT

How can I make it so if nothing exists in there, it will do something/
devTree
#139815284Thursday, July 10, 2014 12:15 AM GMT

Either you didn't define curDS properly, and/or Bag doesn't exist.
devTree
#139815336Thursday, July 10, 2014 12:15 AM GMT

Btw, what the hell is curDS, exactly?
Tynexx
#139817213Thursday, July 10, 2014 12:32 AM GMT

help

    of     1