- What do you want to achieve?
I have gamepasses called starter packs. Each will provide a few skins AND the most important thing: coins. I want the coins to be given once and never again kinda like a starter bonus.
- What is the issue?
I got something set up, but I realized that it isn’t the smartest idea. I let the script detect if the player owns the gamepass first of all, then if the player owns the badge given alongside the gamepass. If the player has the gamepass and not the badge yet, it will be rewarded with coins (player just bought the gamepass). Everything works perfectly fine, except the fact that you can delete badges from your inventory and repeat the process and get coins again and again.
I’d prefer to have a bool value inside the player which saves to determine whether they have received the reward yet or no.
It would be nice if one of you guys can combine it with DataStore2 as I am using this as my saving method!
local Players = game:GetService('Players')
local BadgeService = game:GetService('BadgeService')
local MarketPlaceService = game:GetService('MarketplaceService')
local GamepassId = id
local BadgeId = 788788663135547
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamepassId) then
if not (BadgeService:UserHasBadgeAsync(player.UserId, BadgeId)) then
local coinsDataStore = DataStore2("coins",player)
coinsDataStore:Increment(5000)
wait(2)
BadgeService:AwardBadge(player.UserId, BadgeId)
print("awarded")
end
end
end)
end)
Any help appreciated!