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

Want to data save for my scoring system, but it doesn't work?

I have tried so many data save methods and NONE of them work for me. Hopefully you guys will be able to help.

GemsStore = game:GetService("DataStoreService"):GetDataStore("DataStore")


game.Players.PlayerAdded:connect(function(plr)
	local stats = Instance.new('Folder', plr)
	stats.Name = 'leaderstats'
	local Gems = Instance.new('IntValue', stats)
	Gems.Name = 'Gems'
	Gems.Value = GemsStore:GetAsync(plr.UserId) or 0
	
	if GemsStore:GetAsync("Points_"..plr.Name) ~= nil then
		Gems.Value = GemsStore:GetAsync("Points "..plr.Name)
	else
		Gems.Value = 0
		end
	
	Gems.Changed:connect(function(Val)
		GemsStore:SetAsync("Points "..plr.Name, Val)
		
end)
end)

1 answer

✓ Accepted answer

Should work now. You had SetAsync and GetAsync with different names liek 'points_name' or 'points name' etc. Make sure in your configuration in your place you should have Save API enabled.


GemsStore = game:GetService("DataStoreService"):GetDataStore("DataStore")


game.Players.PlayerAdded:connect(function(plr)
    local stats = Instance.new('Folder', plr)
    stats.Name = 'leaderstats'
    local Gems = Instance.new('IntValue', stats)
    Gems.Name = 'Gems'
    Gems.Value = GemsStore:GetAsync("Points_"..plr.Name) or 0

    if GemsStore:GetAsync("Points_"..plr.Name) ~= nil then
        Gems.Value = GemsStore:GetAsync("Points_"..plr.Name)
    else
        Gems.Value = 0
        end

    Gems.Changed:connect(function(Val)
        GemsStore:SetAsync("Points_"..plr.Name, Val)

end)
end)

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