I’m trying to have a 10 robux donation chest and a 100 robux donation chest next to each other, and whenever I use one both of them update an increased value of their own donation amount. For example if I donate to the 10 chest once the 100 chest displays 100.
While going over the scripts I thought I gave each a unique key for datastore so I’m not quite sure how they’re updating each other because the syntax is a little too advanced for me.
10 script:
local ProductID = 1185190225
local ProductPrice = 10
local CurrencyTypeA = "R$" -- ROBUX > "R$"
local Debounce2 = true
local DS = game:GetService("DataStoreService"):GetDataStore("Places")
local MS = game:GetService("MarketplaceService")
if not DS:GetAsync(CurrencyTypeA.."_RaisedA") then
DS:SetAsync(CurrencyTypeA.."_RaisedA",0)
end
local Raised = DS:GetAsync(CurrencyTypeA.."_RaisedA")
script.Parent.SurfaceGui.RaisedA.ROBUX.Text = CurrencyTypeA.." "..DS:GetAsync(CurrencyTypeA.."_RaisedA")
function PrintOut(Value)
print(Value)
end
script.Parent.CD.MouseClick:connect(function(Player)
if Debounce2 then
if Player.userId > 0 then
--print 'Player is not a Guest!'
MS:PromptProductPurchase(Player,ProductID)
end
end
end)
MS.PromptProductPurchaseFinished:connect(function(UserId,ProductId,IsPurchased)
if Debounce2 then
Debounce2 = false
if IsPurchased then
DS:IncrementAsync(CurrencyTypeA.."_RaisedA",ProductPrice)
DS:OnUpdate(CurrencyTypeA.."_RaisedA",PrintOut)
script.Parent.SurfaceGui.RaisedA.ROBUX.Text = CurrencyTypeA.." "..DS:GetAsync(CurrencyTypeA.."_RaisedA")
script.Parent.Jingle.Volume = 1
script.Parent.Purchased:play()
script.Parent.Jingle:play()
wait(7)
for i = .5,0,-.05 do
script.Parent.Jingle.Volume = i
wait()
end
script.Parent.Jingle:stop()
end
Debounce2 = true
end
end)
coroutine.resume(coroutine.create(function()
while wait(10) do
local Raised = DS:GetAsync(CurrencyTypeA.."_RaisedA")
script.Parent.SurfaceGui.RaisedA.ROBUX.Text = CurrencyTypeA.." "..DS:GetAsync(CurrencyTypeA.."_RaisedA")
end
end))
100 script:
--By DrakesANumma
local ProductID = 1185189768 --do not change
local ProductPrice = 100
local CurrencyTypeB = "R$" -- ROBUX > "R$" | Tickets > "TIX"
local Debounce1 = true
local DS = game:GetService("DataStoreService"):GetDataStore("Places")
local MS = game:GetService("MarketplaceService")
if not DS:GetAsync(CurrencyTypeB.."_RaisedB") then
DS:SetAsync(CurrencyTypeB.."_RaisedB",0)
end
local Raised = DS:GetAsync(CurrencyTypeB.."_RaisedB")
script.Parent.SurfaceGui.RaisedB.ROBUX.Text = CurrencyTypeB.." "..DS:GetAsync(CurrencyTypeB.."_RaisedB")
function PrintOut(Value)
print(Value)
end
script.Parent.CD.MouseClick:connect(function(Player)
if Debounce1 then
if Player.userId > 0 then
--print 'Player is not a Guest!'
MS:PromptProductPurchase(Player,ProductID)
end
end
end)
MS.PromptProductPurchaseFinished:connect(function(UserId,ProductId,IsPurchased)
if Debounce1 then
Debounce1 = false
if IsPurchased then
DS:IncrementAsync(CurrencyTypeB.."_RaisedB",ProductPrice)
DS:OnUpdate(CurrencyTypeB.."_RaisedB",PrintOut)
script.Parent.SurfaceGui.RaisedB.ROBUX.Text = CurrencyTypeB.." "..DS:GetAsync(CurrencyTypeB.."_RaisedB")
script.Parent.Jingle.Volume = 1
script.Parent.Purchased:play()
script.Parent.Jingle:play()
wait(7)
for i = .5,0,-.05 do
script.Parent.Jingle.Volume = i
wait()
end
script.Parent.Jingle:stop()
end
Debounce1 = true
end
end)
coroutine.resume(coroutine.create(function()
while wait(10) do
local Raised = DS:GetAsync(CurrencyTypeB.."_RaisedB")
script.Parent.SurfaceGui.RaisedB.ROBUX.Text = CurrencyTypeB.." "..DS:GetAsync(CurrencyTypeB.."_RaisedB")
end
end))
Thanks to anyone for pointing me in the right direction! I’m new to gamepasses so even modding this stock donation chest is a learning experience for me!