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

Can someone figure out the error in my data store script?

I have my leaderboard properly made. I need it to save using data stores, but my script isn't working.

datastore = game:GetService("DataStoreService"):GetDataStore("Growth")

game.Players.PlayerAdded:connect(function(player)
	player:WaitForDataReady()
	wait(1)
	local stats = player:FindFirstChild("leaderstats").Growth.Value
	stats = datastore:GetAsync(player.UserId)
end)

for i,v in pairs(game.Players:GetChildren()) do
	for x,c in pairs(v:FindFirstChild("leaderstats")) do
		for a,b in pairs(c:FindFirstChild("Growth")) do
			b.Changed:connect(function()
				datastore:SetAsync(v.UserId, b.Value)
			end)
		end
	end
end

2 comments

0

Please give us a start to what's wrong.

0

I don't know where the error is.

1 answer

Try replacing FindFirstChild with WaitForChild. Also don't do this, because if the value defined is to be changed, the old one is still saved.

value = test.Value
print(value)

use this instead

value = test
print(test.Value)

1 comment

0

I replaced the FindFirstChild with WaitForChild, but it still hasn't worked yet.

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