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

Datastore is not saving saving changes in data despite no errors in output?

Hi I have been trying to code a data store and have run into an issue with the code I am trying to use

the script doesn't show any errors in the output bar, it just does not save any change in the data so at this point I am at a loss for what to do

local DSS = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local Server = game:GetService("ServerStorage")

local DS = DSS:GetDataStore("Eldaronservertest1238")

Players.PlayerAdded:Connect(function(Player)
	if Player ~= nil then 
		local UserId = Player.UserId
		local Key = "KeyScope:  "..UserId
		local MyData = DS:GetAsync(Key)
		local Folder = Instance.new("Folder")
		Folder.Name = tostring(UserId)
		local currency = Instance.new("NumberValue")
		Folder.Parent = Server
		currency.Name = "Bitcoin"
		currency.Parent = Folder
		
		local Success, Err = pcall(function()
			if MyData then
				currency.Value = MyData[1]
			else
				currency.Value = 500
				
			end
		end)
		
	if Success then print("Success")
	else
		warn("epic fail  "..Err)
	end		

	end
end)

Players.PlayerRemoving:Connect(function(Player)
	local UserId = Player.UserId
	local Key = "KeyScope:  "..UserId
	local Folder = Server[UserId]
	local Mydata = {Folder.Bitcoin.Value}
	
	DS:GetAsync(Key, Mydata)
	warn("Player data saved for:  "..UserId)
	
end)

1 answer

Issue was I put GetAsync at the bottom of the script instead of SetAsync

1 comment

0

... plox proof read your code before you post a question.

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