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

Data Save Help?

So its not saving this stuff and I need some help fixing it. If someone could please fix this I would jump in joy :)

local DSS = game:GetService('DataStoreService'):GetDataStore('Credits')
local Sp = game:GetService('DataStoreService'):GetDataStore('Speed')
function save(plr, value)
	DSS:UpdateAsync(plr.userId, function(Data)
		Sp:UpdateAsync(plr.userId, function(Datas)
			return value
		end)
	end)
end
function loads(plr)
	return Sp:GetAsync(plr.userId) or Sp:SetAsync(plr.userId, 0) and 0
end

function load(plr)
	return DSS:GetAsync(plr.userId) or DSS:SetAsync(plr.userId, 0) and 0
end

game.Players.PlayerAdded:connect(function(plr)
	local points = Instance.new('IntValue', plr)
	points.Name = 'Credits'
	points.Value = load(plr)
	local speed = Instance.new('IntValue', plr)
	speed.Name = "Speed"
	speed.Value = loads(plr)
	plr.PlayerGui.Menu.Credits.Text = "Credits: "..plr:FindFirstChild("Credits").Value
	points.Changed:connect(function()
		plr.PlayerGui.Menu.Credits.Text = "Credits: "..plr:FindFirstChild("Credits").Value
	end)
end)

game.Players.PlayerRemoving:connect(function(plr)
	save(plr, plr.Credits.Value)
	save(plr, plr.Speed.Value)
end)

1 answer

Please take a look at this page on how to post good questions. It helps a lot if you would edit your question accordingly.

I am really missing an explanation. Your code seems to have a few logic problems, which can only be solved if we can fully understand what your are trying to achieve.

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