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

My datastore isn't saving the data that I give it, & it's not giving me an error?

Hey, I'm pretty new to datastores, anyway I'm trying to save 3 IntValues but it's not working. I can't be sure if it's not saving it, or if it's not loading it because the script isn't giving me an error.

Here's some pictures of my issue & my script.

http://cameronschoenecker.com/im1.PNG

http://cameronschoenecker.com/im2.PNG

6 comments

0

When they leave, unique key is nil.

0

wait nvm

0

userId should be UserId

0

Also, you save copper twice.

0

Oh, haha, thanks, I'll look into those

0

Don't come on this site with alvinbloxx's code, expecting for it to be fixed. Write your own scripts.

1 answer

Delete the IntValues inside of the script (Sounds weird, but trust me). Put this script in a ServerScript in ServerScriptService

local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("GoldSaveSystem")
local ds2 = datastore:GetDataStore("SilverSaveSystem")
local ds3 = datastore:GetDataStore("CopperSaveSystem")

game.Players.PlayerAdded:Connect(function(plr)
	local folder = Instance.new("Folder", plr)
	folder.Name = "leaderstats"
	local Gold = Instance.new("IntValue", folder)
	Gold.Name = "Gold"
	local Silver = Instance.new("IntValue", folder)
	Silver.Name = "Silver"
	local Copper = Instance.new("IntValue", folder)
	Copper.Name = "Copper"
	
	Gold.Value = ds1:GetAsync(plr.UserId) or 0
	ds1:SetAsync(plr.UserId, Gold.Value)
	
	Silver.Value = ds2:GetAsync(plr.UserId) or 0
	ds2:SetAsync(plr.UserId, Silver.Value)
	
	Copper.Value = ds3:GetAsync(plr.UserId) or 0
	ds3:SetAsync(plr.UserId, Copper.Value)
	
	Gold.Changed:Connect(function()
		ds1:SetAsync(plr.UserId, Gold.Value)
	end)
	
	Silver.Changed:Connect(function()
		ds2:SetAsync(plr.UserId, Silver.Value)
	end)
	
	Copper.Changed:Connect(function()
		ds3:SetAsync(plr.UserId, Copper.Value)
	end)
end)

1 comment

0

wowee, that's a lot. Instead of giving me a script I don't understand(which I do appreciate), could you possibly tell me what I'm doing wrong?

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