So I have a game, it has a system where you get coins andd all that, but i want to add a double points gamepass, i tried searching for a tutorial on youtube but there were very few and they were not very good to say the least. I was wondering if anyone could help me!
1 Like
Here’s how you could handle everything
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local GamePassId = 0 -- replace with your gamepass id
Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
local Coins = Instance.new("NumberValue") -- (an example value, use your coins value instead)
Coins.Name = "Coins"
Coins.Value = 1
Coins.Parent = leaderstats
local Multiplier = Instance.new("NumberValue")
Multiplier.Name = "Multiplier"
Multiplier.Value = 1
Multiplier.Parent = player
leaderstats.Parent = player
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamePassId) then -- if player purchased the gamepass before then
Multiplier.Value = 2
end
--------------- an example for coin giving function
task.wait(10)
Coins.Value += 100 * Multiplier.Value
end)
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, id, purchased)
if id == GamePassId and purchased then
player.Multiplier.Value = 2
end
end)
2 Likes