Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataStore2 sends entire store to :AfterSave #96

Open
ghost opened this issue Mar 10, 2020 · 0 comments · May be fixed by #196
Open

DataStore2 sends entire store to :AfterSave #96

ghost opened this issue Mar 10, 2020 · 0 comments · May be fixed by #196
Labels

Comments

@ghost
Copy link

ghost commented Mar 10, 2020

Code snippet (not full code) I was using in my game:

local DataStore2 = require(game.ServerStorage.DataStore2)

local DataStoreService = game:GetService("DataStoreService")
local totalKillsODS = DataStoreService:GetOrderedDataStore("TotalKills") 

DataStore2.Combine("CombatData", "totalKills")


local function makeStatsForPlayer(player)
	local killStore = DataStore2("totalKills", player)
	
	local totalKills = Instance.new("IntValue")
		totalKills.Name = STAT_NAMES.Total_Kills
		totalKills.Value = killStore:Get(0)
		totalKills.Parent = leaderstats
		
	killStore:OnUpdate(function(updatedTotalKills)
		totalKills.Value = updatedTotalKills
	end)
	
	killStore:AfterSave(function(combatData)
		-- combatData is NOT "totalKills" value, It's entire store.
		local total = DataStore2("totalKills", player):Get() -- Hacky way of grabbing totalKills.
	end)
	
	return leaderstats
end
@ghost ghost changed the title DataStore2 sends entire store to :AfterSave, and cannot yield in :AfterSave DataStore2 sends entire store to :AfterSave Mar 10, 2020
@Lordnoobstan Lordnoobstan linked a pull request Sep 1, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant