Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

DataStore always saves but, today it didn't? Can't figure out why.

The DataStore I made always saves but earlier today, it didn't. I'm super curious to figure out why but I couldn't think of anything. Can someone help me figure out why it would fail like that?

game.Players.PlayerRemoving:connect(function(player)
	local datastore = game:GetService("DataStoreService"):GetDataStore(player.UserId.."Save")

local statstorage = player:FindFirstChild("Currency"):GetChildren()
for i =  1, #statstorage do
	datastore:SetAsync(statstorage[i].Name, statstorage[i].Value)
	print("saved data number "..i)
	
end
print("Stats successfully saved")	
end)

game.Players.PlayerAdded:connect(function(player)
		local datastore = game:GetService("DataStoreService"):GetDataStore(player.UserId.."Save")
	
	player:WaitForChild("Currency")
	wait(1)
	local stats = player:FindFirstChild("Currency"):GetChildren()
	for i = 1, #stats do			
	stats[i].Value = datastore:GetAsync(stats[i].Name)
	print("stat numba "..i.." has been found")
		end
end)

2 comments

0

Did you make an update to it and then it stopped working? Are there any errors or warnings or anything in output?

0

I didn't change anything about it. And no, they isn't any errors or warnings.

1 answer

✓ Accepted answer

To be honest, I'd use google docs as a database, yes it uses web hooks and there's a limit but if you're game is a 24 or less players allowed this is perfect. https://devforum.roblox.com/t/using-google-spreadsheets-as-a-database/12658 -Its more organised, Its also great for receiving loss data.- I know it has nothing to do with your question, I just wanted to spread the word and seen as you was talking about database I thought I'd show.

3 comments

0

My game is 10 - 12 players, should I still use google spreadsheets?

0

I would, its more organised and easy to find loss data.

0

Thank you, I'll look into it.

This discussion is preserved as it was. New answers, comments, and votes are closed.