Hello,

My datastore is not saving anything and I am not getting any errors, I am stumped

Any help would be greatly appreciated. API is enabled in settings as well.

local Datastore = game:GetService("DataStoreService"):GetDataStore("DataValues")

game.Players.PlayerAdded:Connect(function(player)

	local Folder = Instance.new("Folder", player)
	Folder.Name = "StatData"
	
	local cR = Instance.new("IntValue", Folder)
	cR.Name = "cR"
	
	local cRBank = Instance.new("IntValue", Folder)
	cRBank.Name = "cRBank"
	
	local Ore = Instance.new("IntValue", Folder)
	Ore.Name = "Ore"
	
	local Iron = Instance.new("IntValue", Ore)
	Iron.Name = "Iron"
	
	local Silicon = Instance.new("IntValue", Ore)
	Silicon.Name = "Silicon"
	
	local Nickel = Instance.new("IntValue", Ore)
	Nickel.Name = "Nickel"
	
	local Titanium = Instance.new("IntValue", Ore)
	Titanium.Name = "Titanium"
	
	local Platinum = Instance.new("IntValue", Ore)
	Platinum.Name = "Platinum"
	
	local Palladium = Instance.new("IntValue", Ore)
	Palladium.Name = "Palladium"
	
	local Phosphorus = Instance.new("IntValue", Ore)
	Phosphorus.Name = "Phosphorus"
	
	local Notoriety = Instance.new("IntValue", Folder)
	Notoriety.Name = "Notoriety"
	
	local ShipObject = Instance.new("ObjectValue", Folder)
	ShipObject.Name = "Ship"
	

	local key = "User - " .. player.UserId
	
	local storeditems = Datastore:GetAsync(key)
	if storeditems then
		cR.Value = storeditems[1]
		cRBank.Value = storeditems[2]
		Ore.Value = storeditems[3]
		Notoriety.Value = storeditems[4]
	else
		local items = {cR.Value, cRBank.Value, Ore.Value, Notoriety.Value}
		Datastore:SetAsync(key, items)
	end	
end)

game.Players.PlayerRemoving:Connect(function(player)
	local items = {player.StatData.cR.Value, player.StatData.cRBank.Value, player.StatData.Ore.Value, player.StatData.Notoriety.Value}
	local key = "User-" .. player.UserId
	Datastore:SetAsync(key, items)
end)

5 comments

0

player.userId needs to be player.UserId didnt read whole script but that's one thing that's gonna error

0

Ah, gotcha.

0

Are there any output errors

0

No, none still. its weird, maybe Roblox finally just broke it.

0

Still havent been able to find the problem, despite tons of editing, etc...