Trouble using MarketPlaceService

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to make a bomb inserted into player once a bool value (Round) changes
  2. What is the issue? Include screenshots / videos if possible!
    For some reason, It doesn’t work, the bomb doesn’t insert into player and nothing happens
    The output says “Unable to cast instacne to int64”
	if Round.Value == true then
		for i, player in pairs(game.Players:GetChildren()) do
			local character = player.Character
			character.HumanoidRootPart.CFrame = GameAreaSpawn.CFrame
			
			if MarketPlace:UserOwnsGamePassAsync(player.UserId, GamePassID) then
				local Bomb2 = Bomb:Clone()
				Bomb2.Parent = player.Backpack
			end
			
			
			wait(1)	
				local Gear = game.ServerStorage.Gear:Clone()
				Gear.Parent = player.Backpack
			end
		

1 Like

This part of code seems to be fine, is the error at the line where you clone the bomb? If yes then can we see the part of the script where you make the variable “Bomb2”?

1 Like

UserOwnsGamePassAsync expects a UserId and an Id for the gamepass to check so there’s nothing wrong there, unless GamePassID is an instance, can we see how you make the GamePassID variable?

Or you have other UsreOwnsGamePassAsync checks in which case we may need to see them as well

1 Like

No, it’s not I’m not sure where it is

1 Like

local gamepassid = [ID here] ⠀⠀⠀⠀⠀

1 Like

Do you use UserOwnsGamePassAsync or similar anywhere else in your code?

1 Like

No,But I have this script

local Players            = game:GetService("Players")

local Bomb               = game.ServerStorage.C4
local GamePassID         = 17039941



function InsertBombIntoPlayer(Player) 
    local Bomb2 = Bomb:Clone()
    Bomb2.Parent = Player.StarterGear
    Bomb2 = Bomb:Clone()
    Bomb2.Parent = Player.Backpack
end

Players.PlayerAdded:Connect(function(Player)
    if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamePassID) then
        InsertBombIntoPlayer(Player)
    end
end)

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(Player, purchasePassID, purchaseSuccess)
    if not purchaseSuccess then return end
    if purchasePassID == GamePassID then
        print(Player.Name .. " bought the bomb gamepass!")
        InsertBombIntoPlayer(Player) --//Reward the player with the object on the spot, rather than waiting for them to rejoin
    end
end)
1 Like

The only thing I see wrong is that you odn’t have a variable for MarketplaceService, although you probably forgot to include it in the reply, which in that case, I really don’t see anything wrong here as you do everything proper.

Are you certain it’s not being used anywhere else?

2 Likes