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

How do I save Multiple IntValues in a datastore?

local DataStore = game:GetService("DataStoreService")
local ds1 = DataStore:GetDataStore("Point")

game.Players.PlayerAdded:connect(function(player)
	local PointMaster = Instance.new("Folder",player)
	PointMaster.Name = "Points"
	
    local Points = Instance.new('IntValue',PointMaster)
	Points.Name = "Valu"
	Points.Value = ds1:GetAsync(player.UserId) or 0
	ds1:SetAsync(player.UserId,Points.Value)

local Points = Instance.new('IntValue',PointMaster) 
    Points.Name = "EXP"
    Points.Value = ds1:GetAsync(player.UserId) or 0
    ds1:setAsync(player.UserId,Points.Value)

	
	
	Points.Changed:connect(function()
		ds1:SetAsync(player.UserId,Points.Value)
		print("Points Saved!")
		
		exp.Changed:connect(function()
			ds1:setAsync(player.UserId,exp.Value)
			print("EXP Saved!")
		end)

	end)
end)

game.Players.PlayerRemoving:connect(function(player)
	ds1:SetAsync(player.UserId, player.Points.Points.Value)
	
	print("Data Saved")
	
end)
This is what I've tried.

Can someone help or correct this?

1 answer

✓ Accepted answer

That should work... Unless you want them to be 2 different data stores. This one data store with 2 variables, which would work also.

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