I have a gamepass for my game, that will add 10,000 money when bought. I have 2 others for 1,000 and 100 money. Currently the script, which is just my leaderstats script, wont add the money. How do I make the moneys add?
local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("officialpointfortlolSaveSystem")
local gamepass_id1 = 18287787
local gamepass_id2 = 18287797
local gamepass_id3 = 18309443
local stat = "Changes"
local gamepass_stat1 = 100
local gamepass_stat2 = 1000
local gamepass_stat3 = 10000
game.Players.PlayerAdded:connect(function(plr)
local folder = Instance.new("Folder", plr)
folder.Name = "leaderstats"
local gems = Instance.new("IntValue", folder)
gems.Name = "Changes"
gems.Value = ds1:GetAsync(plr.UserId) or 0
ds1:SetAsync(plr.UserId, gems.Value)
gems.Changed:connect(function()
ds1:SetAsync(plr.UserId, gems.Value)
local award3 = Instance.new("BoolValue", plr)
award3.Name = "Award3"
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId, gamepass_id3) and plr.Award3.Value == false then
plr.Award3.Value = true
gems.Value = gems.Value + gamepass_stat3
end
end)
end)
while wait(3) do
for i, v in pairs(game.Players:GetChildren()) do
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(v.UserId, gamepass_id3) and v:WaitForChild("Award3").Value == false then
v.Award1.Value = true
v.leaderstats:FindFirstChild(stat).Value = v.leaderstats:FindFirstChild(stat).Value + gamepass_stat3
end
end
end
game.ReplicatedStorage.re.OnServerEvent:Connect(
function(player)
player.leaderstats.Changes.Value += 1
end
)
