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

My dataStore loads random data?

Some Players in my game have complained about having their Data being changed on entering a different server,some aren't affected and some say that it happens when I use the shutdown all servers button . Apparently the intValues that the datastores are saving are being replaced by random numbers?

I can't seem to find anything wrong with the scripts. I'm hoping someone else can review my script and reassure this should work as intended.

local saveAs = "HS"

local dataStore = game:GetService("DataStoreService"):GetDataStore(saveAs)
local Players = game:GetService("Players")

Players.PlayerAdded:connect(function(player)
	local stats = player:WaitForChild("Hstats")
	local data = dataStore:GetAsync(player.UserId)
	if data then
		for name,value in next, data do
			stats[name].Value = value 
		end
	end
end)

Players.PlayerRemoving:connect(function(player)
	local stats = player:FindFirstChild("Hstat")
	if stats then
		local data = {}
		for _,stat in ipairs(stats:GetChildren()) do
			data[stat.Name] = stat.Value
		end
		dataStore:SetAsync(player.UserId,data)
	end
end)

while wait(61) do
    for _, player in pairs(game.Players:GetChildren()) do
local stats = player:FindFirstChild("Hstat")
	if stats then
		local data = {}
		for _,stat in ipairs(stats:GetChildren()) do
			data[stat.Name] = stat.Value
		end
		dataStore:SetAsync(player.UserId,data)
	end
end
end 



game.OnClose = function()
	wait(10)
end



1 answer

✓ Accepted answer

This is my best guess. The HS data store probably is used in more games then just yours. Other games are able to change your datastore also, so you should name it something unique, e.x. HS9280924. Also in case someone on scriptinghelpers is trolling, I would not actually post the datastore on here.

2 comments

0

Did not know about that o_o thanks for letting me know.

0

Im sorry, but according to the wiki, and some other person, it can only be changed from your game/universe. But thats still the only reason I can think of without seeing your script to get the info.

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