I've tried alot and cant seem to get it to save. At line 9 it also says argument 1 missing or nil I'd also like to know why. The main point of what I'm trying to do is save a Table, so focus on that.
DS = game:GetService("DataStoreService"):GetDataStore('gearvaleuz') http = game:GetService('HttpService') --Loading Data local function PlrAdd(player) local GearDataLoad = game.ReplicatedStorage:WaitForChild('profile'):WaitForChild(player.Name):WaitForChild('GearData') LD = http:JSONDecode(DS:GetAsync('GearColor')) GearColorLoad = { Color1 = Color3.fromRGB(LD['GClr'][1],LD['GClr'][2],LD['GClr'][3]) } local Gear = workspace:WaitForChild(player.Name..'s Gear') Gear:WaitForChild('GearColorValue').Value = GearColorLoad[1] end --Saving Data game.Players.PlayerRemoving:connect(function(plr) local GearDataSave = game.ReplicatedStorage:WaitForChild('profile'):WaitForChild(plr.Name):WaitForChild('GearData') GearColorSave= httpJSONEncode({ ['GClr'] = { GearDataSave.GearColor.Value.r, GearDataSave.GearColor.Value.g, GearDataSave.GearColor.Value.b } }) DS:SetAsync('GearColor',GearColorSave) end) game.Players.PlayerAdded:connect(PlrAdd)
Thank you for taking your time to read this.
You're trying to take data out of an empty datastore, that's why it's nil, you save the data afterwords. So when a player enters the game they have no "GearColor" data, and when you try to retrieve it, it's "nil", so the error is correct, you're trying to Decode absolutely nothing.
instead try this
local function PlrAdd(player) local GearDataLoad = game.ReplicatedStorage:WaitForChild('profile'):WaitForChild(player.Name):WaitForChild('GearData') if DS:GetAsync('GearColor') ~= nil then LD = http:JSONDecode(DS:GetAsync('GearColor')) GearColorLoad = { Color1 = Color3.fromRGB(LD['GClr'][1],LD['GClr'][2],LD['GClr'][3]) } local Gear = workspace:WaitForChild(player.Name..'s Gear') Gear:WaitForChild('GearColorValue').Value = GearColorLoad[1] end end