Im a bit new with datastores. I want to have across experience donation board, so that everyone in every server can see how much robux is raised as a donation. I am using DataStore for that. Here is relevant part of the code of donating.
local MarketplaceService = game:GetService("MarketplaceService")
local DonationStore = game:GetService("DataStoreService"):GetDataStore("BardDonations")
--local xpupdate = game.ReplicatedStorage:WaitForChild("xpupdate")
local donate10ID = 1265124435
local donate100ID = 1265125116
local donate500ID = 1265125250
local function processReceipt(receiptInfo)
local player = players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if receiptInfo.ProductId == donate10ID then
if player then
game.Workspace.CurrentConst.Bar.Bard.Head.Goal:Play()
local currentDon = DonationStore:GetAsync("BardDonations")
DonationStore:UpdateAsync("BardDonations", currentDon+10)--DonationStore:SetAsync("BardDonations", 10)
end
end
It works and purchase processes, as the goal sound plays.
And this is the code inside a textlabel on which it should say how much is raised.
local Raised = script.Parent:WaitForChild("SurfaceGui"):WaitForChild("TextLabel")
local DonationStore = game:GetService("DataStoreService"):GetDataStore("BardDonations")
local currentDon = DonationStore:GetAsync("BardDonations")
Raised.Text = "Robux Raised:"..tostring(currentDon)
while task.wait(10) do
local currentDon = DonationStore:GetAsync("BardDonations")
Raised.Text = "Robux Raised:"..tostring(currentDon)
end
but it says “Robux Raised: Nil”, which i think means that i am updating datastore wrong.
But I cant figure out what am I doing wrong.
There are no errors in the output, if anyone has solutions, please help