How to stop the advice "You already own this item. Your account has not been charged"

Hi everyone, I made a button when you click it it pop up the gamepass, but the problem is when player already own the gamepass, appears an advice “you already own this item. you account has not been charged”, I tried with PromptGamePassPurchaseFinished, but it didn’t work.

Here is the code:
local MPS = game:GetService(‘MarketplaceService’)
local Player = game.Players.LocalPlayer
local RE = game.ReplicatedStorage:WaitForChild(“ChangePlayerCharacter”)
local characterValue = script.Parent:WaitForChild(“CharacterName”)
local istrue = false
local Ttime = 1
local ID = 75665424

MPS:PromptGamePassPurchase(Player,ID)

if MPS:UserOwnsGamePassAsync(Player.UserId, ID) then

script.Parent.MouseButton1Click:Connect(function(player)
	if istrue == false then
		istrue = true
		script.Parent.Check.Visible = true
		local charactername = characterValue.Value
		RE:FireServer(charactername)
	end
end)

RE.OnClientEvent:Connect(function()
	wait(Ttime)
	istrue = false
	local function gamepassPurchaseFinished(...)
		print("PromptGamePassPurchaseFinished")
	end
	MPS.PromptGamePassPurchaseFinished:Connect(gamepassPurchaseFinished)
end)

end

Gamepasses can only be owned one at a time. Since you’re the creator of the gamepass, you already have the gamepass owned, this is why you’re getting the message.

1 Like

yes, but how can I get remove it, or you can’t?, it appears each time you click it

You can remove gamepasses from your inventory,by going to your inventory in the Roblox website. https://www.roblox.com/users/UserId/inventory#!/passes

1 Like

oh no sorry, I don’t know if was not be clear my topic, I will edited again, the main problem is when player own the gamepass, and the player clicks again the skin to equip again, the advice appear

In other words, you want the player to be able to buy the gamepass multiple times?

1 Like

no, I just want to stop pop up that advice when player already own the gamepass, is it possible?

In this line, put the not keyword after the if keyword. Your mistake was checking if the player owns the gamepass before purchasing, which kinda makes it impossible to purchase if the player doesn’t own the gamepass from the start. But the script is supposed to check if the player doesn’t own the gamepass before they can purchase it.

New Script
local MPS = game:GetService('MarketplaceService')
local Player = game.Players.LocalPlayer
local RE = game.ReplicatedStorage:WaitForChild("ChangePlayerCharacter")
local characterValue = script.Parent:WaitForChild("CharacterName")
local istrue = false
local Ttime = 1
local ID = 75665424

script.Parent.MouseButton1Click:Connect(function(player)
	if not MPS:UserOwnsGamePassAsync(Player.UserId, ID) then
		if istrue == false then
			istrue = true
			script.Parent.Check.Visible = true
			local charactername = characterValue.Value
			RE:FireServer(charactername)
		end
	end
end)

RE.OnClientEvent:Connect(function()
	wait(Ttime)
	istrue = false
	local function gamepassPurchaseFinished(...)
		print("PromptGamePassPurchaseFinished")
	end
	MPS.PromptGamePassPurchaseFinished:Connect(gamepassPurchaseFinished)
end)
1 Like

Yes, just check if the player owns the gamepass and if so, don’t prompt the purchase.

I’ll make a script real quick.

1 Like

You can go to “players and servers” and start a game with 1 player to get the prompt you want.

1 Like

Try this:

--//Services
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")

--//Variables
local LocalPlayer = Players.LocalPlayer
local RE = ReplicatedStorage:WaitForChild("ChangePlayerCharacter")
local characterValue = script.Parent:WaitForChild("CharacterName")

--//Controls
local istrue = false
local Ttime = 1
local ID = 75665424

--//Functions
if not MarketplaceService:UserOwnsGamePassAsync(LocalPlayer.UserId, ID) then
	MarketplaceService:PromptGamePassPurchase(LocalPlayer, ID)
end

script.Parent.MouseButton1Click:Connect(function(player)
	if not istrue then
		istrue = true
		script.Parent.Check.Visible = true
		
		local charactername = characterValue.Value
		RE:FireServer(charactername)
	end
end)

Also next time, please format your code correctly.

umm, I just used it, but now I can’t be the skin selected

okay, thank you so much, let me tried

Hello? I fixed the code, I needed to load into studio because it’s kinda hard to format here…

local MPS = game:GetService('MarketplaceService')
local Player = game.Players.LocalPlayer
local RE = game.ReplicatedStorage:WaitForChild("ChangePlayerCharacter")
local characterValue = script.Parent:WaitForChild("CharacterName")
local Ttime = 1
local ID = 75665424

script.Parent.MouseButton1Click:Connect(function(player)
	if not MPS:UserOwnsGamePassAsync(Player.UserId, ID) then
		script.Parent.Check.Visible = true
		local charactername = characterValue.Value
		RE:FireServer(charactername)
	end
end)

RE.OnClientEvent:Connect(function()
	wait(Ttime)
	istrue = false
	local function gamepassPurchaseFinished(...)
		print("PromptGamePassPurchaseFinished")
	end
	MPS.PromptGamePassPurchaseFinished:Connect(gamepassPurchaseFinished)
end)

It should work, otherwise it’s an issue with your code.

1 Like

I just tried your code, but it still appearing the advice

Do you prompt the purchase on the server? Also I don’t get how in the video it prompts the purchase, even though the code wouldn’t allow that without erroring due to the formatting.

1 Like

umm, I think it’s a problem with my script, it now not let me be the skin

yes, I do, oh let me upload another video, but it works clicking the Image Button

You’ll need to check if the player owns the gamepass first.

local GuiDisabled = UserOwnsGamePassAsync(player, gamepassid)

By default this would be false if the player does not own the gamepass.
in the mousebuttonclicked event you would need to check if GuiDisabled == false

note: make sure to set the value to true when the player does buy the item or else it won’t update.

1 Like

It does not need to prompted through a serverscript or localscript. It will fire the event either way
He needs to check if the player owns the gamepass and only allow the prompt when the player does not own the gamepass.

Read more here : MarketplaceService | Roblox Creator Documentation

1 Like