I couldn’t manage to figure out how to if the player owns the pass then it gives +500 Points then changes the value in my datastore to true to register that the player has already gotten the reward.
I know the error of why it’s not giving them points I just don’t know how to get around it as I’m a fairly new to scripting on here. It’s because I’m sending it through a script in ServerScriptService I was just wondering if I should fire an event through a LocalScript on purchase then it changes the values, and registers it.
I would just like to see if I could get any help or feedback on how I should go about doing this.
Thanks for reading and for any feedback you can give me.
You can use PromptGamePassPurchaseFinished to process any completed (or rejected) gamepass purchases. You should also process the ownership of this gamepass upon player joining to make sure players who buy it on the webpage also get their reward.
I wouldn’t use a LocalScript for any of this at all.
--Script Made By Theyoloman1920, 30 June 2020
--Services
local MarketPlaceService = game:GetService("MarketplaceService")
--Variables
local GamepassID = --(your gamepass ID)
local Player = game.Players.LocalPlayer
--Script
if MarketPlaceService:UserOwnsGamePassAsync(Player.userId, GamepassID) then
--give to the player the extra points (I guess you already have a point system, so you can add it here)
end
Please tell me if the script worked (note that you will have to make it fire once)
Theyoloman1920
local Players = game:GetService('Players')
local MP = game:GetService('MarketplaceService')
local Id = 10001499
local VIP_Amount = 500
local Default_Amount = 50
Players.PlayerAdded:Connect(function(Player)
local Stats = Instance.new('Configuration')
Stats.Name = 'leaderstats'
Stats.Parent = Player
local Coins = Instance.new('IntValue')
Coins.Name = 'Coins'
Coins.Value = MP:UserOwnsGamePassAsync(Player.UserId, Id) and VIP_Amount or Default_Amount
Coins.Parent = Stats
end)
-- Give them 500 extra coins if they purchase the game pass ingame?
MP.PromptGamePassPurchaseFinished:Connect(function(Player, GamePassId, IsPurchased)
if GamePassId == Id and IsPurchased then
local Stats = Player:FindFirstChild('leaderstats')
if Stats then
local Coins = Stats.Coins
Coins.Value += VIP_Amount
end
end
end)