My game just released and now there is datastore bugs…
local MoneyStore = Datastore2(“Money”, Player)
local LevelStore = Datastore2("Level", Player)
local XpStore = Datastore2("Xp", Player)
local MaxXpStore = Datastore2("MaxXp", Player)
local UnlockedWeaponsStore = Datastore2("UnlockedWeapons", Player)
local UnlockedEffectsStore = Datastore2("UnlockedEffects", Player)
local EffectStore = Datastore2("Effect", Player)
local WeaponStore = Datastore2("Weapon", Player)
local CandyCanesStore = Datastore2("CandyCanes", Player)
local function UpdateCandyCanes(CandyCanesData)
CandyCanes.Value = CandyCanesStore:Get(CandyCanesData)
end
local function UpdateMoney(MoneyData)
Money.Value = MoneyStore:Get(MoneyData)
end
local function UpdateLevel(LevelData)
Level.Value = LevelStore:Get(LevelData)
end
local function UpdateXp(XpData)
Xp.Value = XpStore:Get(XpData)
end
local function UpdateMaxXp(MaxXpData)
MaxXp.Value = MaxXpStore:Get(MaxXpData)
end
local function UpdateEffect(EffectData)
Effect.Value = EffectStore:Get(EffectData)
end
local function UpdateWeapon(WeaponData)
Weapon.Value = WeaponStore:Get(WeaponData)
end
local function UpdateUnlockedWeapons(UnlockedWeaponsData)
UnlockedWeapons:ClearAllChildren()
for i, v in pairs(UnlockedWeaponsData) do
local NewValue = Instance.new("StringValue", UnlockedWeapons)
NewValue.Name = v
end
end
local function UpdateUnlockedEffects(UnlockedEffectsData)
UnlockedEffects:ClearAllChildren()
for i, v in pairs(UnlockedEffectsData) do
local NewValue = Instance.new("StringValue", UnlockedEffects)
NewValue.Name = v
end
end
UpdateCandyCanes(0)
CandyCanesStore:OnUpdate(UpdateCandyCanes)
UpdateMoney(0)
MoneyStore:OnUpdate(UpdateMoney)
UpdateLevel(1)
LevelStore:OnUpdate(UpdateLevel)
UpdateXp(0)
XpStore:OnUpdate(UpdateXp)
UpdateMaxXp(100)
LevelStore:OnUpdate(UpdateMaxXp)
UpdateEffect("OOF")
EffectStore:OnUpdate(UpdateEffect)
UpdateWeapon("Classic Sword")
WeaponStore:OnUpdate(UpdateWeapon)
UpdateUnlockedWeapons(UnlockedWeaponsStore:Get({UnlockedWeaponsTable}))
UnlockedWeaponsStore:OnUpdate(UpdateUnlockedWeapons)
UpdateUnlockedEffects(UnlockedEffectsStore:Get(UnlockedEffectsTable))
UnlockedEffectsStore:OnUpdate(UpdateUnlockedEffects)
if #UnlockedWeapons:GetChildren() == 0 then
table.insert(UnlockedWeaponsStore:Get({UnlockedWeaponsTable}), "Classic Sword")
UnlockedWeaponsStore:Set(UnlockedWeaponsStore:Get({"Classic Sword"}))
end
if #UnlockedEffects:GetChildren() == 0 then
table.insert(UnlockedEffectsStore:Get({UnlockedEffectsTable}), "OOF")
UnlockedEffectsStore:Set(UnlockedEffectsStore:Get({"OOF"}))
end
this is all in a playeradded event i really need help my game has players
Would it work if I set a wait function to the UnlockedWeaponsTable and the UnlockedEffectsTable (the ones that are tables) in between each of the iterations in the for loop?
Answering 18h later because it was urgent
Anyways you could use the debounce function
local LevelStore = Datastore2("Level", Player)
local XpStore = Datastore2("Xp", Player)
local MaxXpStore = Datastore2("MaxXp", Player)
local UnlockedWeaponsStore = Datastore2("UnlockedWeapons", Player)
local UnlockedEffectsStore = Datastore2("UnlockedEffects", Player)
local EffectStore = Datastore2("Effect", Player)
local WeaponStore = Datastore2("Weapon", Player)
local CandyCanesStore = Datastore2("CandyCanes", Player)
local debounceCandyCanes = false
local function debouncedUpdateCandyCanes(CandyCanesData)
if debounceCandyCanes then return end
debounceCandyCanes = true
CandyCanes.Value = CandyCanesStore:Get(CandyCanesData)
debounceCandyCanes = false
end
local debounceMoney = false
local function debouncedUpdateMoney(MoneyData)
if debounceMoney then return end
debounceMoney = true
Money.Value = MoneyStore:Get(MoneyData)
debounceMoney = false
end
local debounceLevel = false
local function debouncedUpdateLevel(LevelData)
if debounceLevel then return end
debounceLevel = true
Level.Value = LevelStore:Get(LevelData)
debounceLevel = false
end
local debounceXp = false
local function debouncedUpdateXp(XpData)
if debounceXp then return end
debounceXp = true
Xp.Value = XpStore:Get(XpData)
debounceXp = false
end
local debounceMaxXp = false
local function debouncedUpdateMaxXp(MaxXpData)
if debounceMaxXp then return end
debounceMaxXp = true
MaxXp.Value = MaxXpStore:Get(MaxXpData)
debounceMaxXp = false
end
local debounceEffect = false
local function debouncedUpdateEffect(EffectData)
if debounceEffect then return end
debounceEffect = true
Effect.Value = EffectStore:Get(EffectData)
debounceEffect = false
end
local debounceWeapon = false
local function debouncedUpdateWeapon(WeaponData)
if debounceWeapon then return end
debounceWeapon = true
Weapon.Value = WeaponStore:Get(WeaponData)
debounceWeapon = false
end
local debounceUnlockedWeapons = false
local function debouncedUpdateUnlockedWeapons(UnlockedWeaponsData)
if debounceUnlockedWeapons then return end
debounceUnlockedWeapons = true
UnlockedWeapons:ClearAllChildren()
for i, v in pairs(UnlockedWeaponsData) do
local NewValue = Instance.new("StringValue", UnlockedWeapons)
NewValue.Name = v
end
debounceUnlockedWeapons = false
end
local debounceUnlockedEffects = false
local function debouncedUpdateUnlockedEffects(UnlockedEffectsData)
if debounceUnlockedEffects then return end
debounceUnlockedEffects = true
UnlockedEffects:ClearAllChildren()
for i, v in pairs(UnlockedEffectsData) do
local NewValue = Instance.new("StringValue", UnlockedEffects)
NewValue.Name = v
end
debounceUnlockedEffects = false
end
debouncedUpdateCandyCanes(0)
CandyCanesStore:OnUpdate(debouncedUpdateCandyCanes)
debouncedUpdateMoney(0)
MoneyStore:OnUpdate(debouncedUpdateMoney)
debouncedUpdateLevel(1)
LevelStore:OnUpdate(debouncedUpdateLevel)
debouncedUpdateXp(0)
XpStore:OnUpdate(debouncedUpdateXp)
debouncedUpdateMaxXp(100)
LevelStore:OnUpdate(debouncedUpdateMaxXp)
debouncedUpdateEffect("OOF")
EffectStore:OnUpdate(debouncedUpdateEffect)
debouncedUpdateWeapon("Classic Sword")
WeaponStore:OnUpdate(debouncedUpdateWeapon)
debouncedUpdateUnlockedWeapons(UnlockedWeaponsStore:Get({UnlockedWeaponsTable}))
UnlockedWeaponsStore:OnUpdate(debouncedUpdateUnlockedWeapons)
debouncedUpdateUnlockedEffects(UnlockedEffectsStore:Get(UnlockedEffectsTable))
UnlockedEffectsStore:OnUpdate(debouncedUpdateUnlockedEffects)
if #UnlockedWeapons:GetChildren() == 0 then
table.insert(UnlockedWeaponsStore:Get({UnlockedWeaponsTable}), "Classic Sword")
UnlockedWeaponsStore:Set(UnlockedWeaponsStore:Get({"Classic Sword"}))
end
if #UnlockedEffects:GetChildren() == 0 then
table.insert(UnlockedEffectsStore:Get({UnlockedEffectsTable}), "OOF")
UnlockedEffectsStore:Set(UnlockedEffectsStore:Get({"OOF"}))
end