Check to see if user owns gamepass help

How would I make it so after the player buys the gamepass it fires the clien??

Event.OnServerEvent:Connect(function(plr)
	if MarketplaceService:UserOwnsGamePassAsync(plr.UserId, GamepassID) then
	plr.axes.Invisaxe.Value = true
	ReplicatedStorage.OnJoin.Invisaxe1:FireClient()
	else
		MarketplaceService:PromptGamePassPurchase(plr, GamepassID)
	end
end)

Use MarketplaceService.PromptGamePassPurchaseFinished. Like this:

Event.OnServerEvent:Connect(function(plr)
	if MarketplaceService:UserOwnsGamePassAsync(plr.UserId, GamepassID) then
		plr.axes.Invisaxe.Value = true
		ReplicatedStorage.OnJoin.Invisaxe1:FireClient()
	else
		MarketplaceService:PromptGamePassPurchase(plr, GamepassID)
		MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, gamePassId, purchased)
			if player ~= plr or not purchased or gamePassId ~= GamePassID then
				return
			end
			-- Guessing that you want to do the same you do when the player originally owns the gamepass.
			plr.axes.Invisaxe.Value = true
			ReplicatedStorage.OnJoin.Invisaxe1:FireClient()
		end)
	end
end)

it is saying argument 1 missing or nil on line 12?

Odd, didn’t test it, let me see what I messed up.

got it


Can you show me what line 12 is?

ReplicatedStorage.OnJoin.Invisaxe1:FireClient()

i checked if it was in the right spot and it is

Oh, I messed it up :skull:
We’re not firing the RemoteEvent to any player.

Event.OnServerEvent:Connect(function(plr)
	if MarketplaceService:UserOwnsGamePassAsync(plr.UserId, GamepassID) then
		plr.axes.Invisaxe.Value = true
		ReplicatedStorage.OnJoin.Invisaxe1:FireClient(plr)
	else
		MarketplaceService:PromptGamePassPurchase(plr, GamepassID)
		MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, gamePassId, purchased)
			if player ~= plr or not purchased or gamePassId ~= GamePassID then
				return
			end
			-- Guessing that you want to do the same you do when the player originally owns the gamepass.
			plr.axes.Invisaxe.Value = true
			ReplicatedStorage.OnJoin.Invisaxe1:FireClient(plr)
		end)
	end
end)
1 Like