hi in my script i have 2 event listeners but for some reason most of the times, the data async function only runs and the other doesnt.
Gold.Changed:Connect(function(value)
print("goldchange")
if prevGold then
print("prevExists")
local infoTable = {PlayerInstance = Player,
PrevAmount = prevGold,
NewAmount = value,
Difference = math.abs(prevGold - value),
Image = goldUI.GoldImage,
StorageIcons = nil,
GoldValueVar = goldUI.GoldValue
}
goldUI.GoldValue.Value = prevGold
prevGold = value
if value < infoTable.PrevAmount then
print("prevgolexists")
local clonesIcon = Instance.new("Frame",Player.PlayerGui.GoldCurrency)
clonesIcon.Name = "Gold"
clonesIcon.Size = UDim2.fromScale(1,1)
clonesIcon.Transparency = 1
infoTable.StorageIcons = clonesIcon
goldUI.GoldValue.Value = infoTable.PrevAmount
generatingIcons(infoTable)
if not cooldownAnim then
cooldownAnim = true
counting(infoTable, goldUI)
cooldownAnim = false
else
goldUI.TextLabel.Text = value
end
else
counting(infoTable)
end
else
print("noPrev")
prevGold = value
end
end)
Gold.Changed:Connect(function(value)
DataStoreGold:SetAsync(Player.UserId, Player.leaderstats.Gold.Value)
end)
as u can see, only the last listener runs and i tried changing positions.