Data store not saving

i have made a data store but it doesnt save anything and im not getting any errors which is annoying as hell
here is the script, i give up. any help very appreciated

> game.Players.PlayerRemoving:Connect(function(plr)
> 	local invbar = plr.PlayerGui.InvBar
> 	local itemstable = {}
> 	local foundtool1 = false
> 	local foundtool2 = false
> 	local foundtool3 = false
> 	for i,v in pairs(invbar.Pickaxe.bg1.ToolImage:GetChildren()) do
> 		if v:IsA("Tool") then
> 			table.insert(itemstable,v.Name)
> 			foundtool1 = true
> 		end
> 	end
> 	if foundtool1 == false then
> 		table.insert(itemstable,"Empty")
> 	end
> 	for i,v in pairs(invbar.Accessory.bg2.ToolImage:GetChildren()) do
> 		if v:IsA("Tool") then
> 			table.insert(itemstable,v.Name)
> 			foundtool2 = true
> 		end
> 	end
> 	if foundtool2 == false then
> 		table.insert(itemstable,"Empty")
> 	end
> 	for i,v in pairs(invbar.Special.bg3.ToolImage:GetChildren()) do
> 		if v:IsA("Tool") then
> 			table.insert(itemstable,v.Name)
> 			foundtool3 = true
> 		end
> 	end
> 	if foundtool3 == false then
> 		table.insert(itemstable,"Empty")
> 	end
> 	local sukces2,blad2 = pcall(function()
> 		invdatastore:SetAsync(plr.UserId,itemstable)
> 	end)
> 	if sukces2 then
> 		print("udao sie")
> 	else
> 		print("cos sie nie udao")
> 		warn(blad2)
> 	end
> end)
3 Likes

try it in a roblox server instead of in roblox studio. Datastores and textfiltering don’t work in roblox studio to prevent a user from making a script outside of roblox’s boundaries that still affects their servers.

1 Like

i was testing it in a roblox server

pretty sure roblox can’t save objects. you’ll need to give them an ID, save the IDs and then them load them in using those IDs from the server.
(ObjectIDs in the datastore)>(Server takes those IDs)>(Server gives the correct objects)

yyyeah it cant save objects so instead of saving objects im saving their names

1 Like

oh yea… my bad.
Are you calling this from the server or the client? you cannot use PlayerRemoving on the client because the localscript would not be running at that point anymore. Also, i’m not seeing anything in that script that would access the datastore to get the names and use them.

it is a server side script so it should be fine

are you using an alt account to view what happens on the server side?|
I too am as confused as you probably are. you might wanna contact roblox with this.

im on my main account and im looking at the server log

it says attempt to inddex nil with number which means the table doesnt exist which means the data store ddidnt save anything

1 Like

i think i’m seeing it. you seem to have forgotten to state where the data needs to be saved in the array.
Table.Insert(Table,Data,Adress)

This is wrong. table.insert does not work like that. If there is no 3rd argument, the 2nd argument is read as the data and it is appended. If you have 3 arguments the 3rd argument is the data and the 2nd is the index.

wait what i dont understand you

Your data isn’t saving (correctly) because client changes to PlayerGui are not replicated to the server.

1 Like