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

When did I say it mattered? I was just asking, due to him firing a remote event and prompting the purchase.

Also because, in his script, he prompts the purchase even before the function is connected.

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")

local Player = -- Determine Player
local BuyButton = script.Parent

local WaitAfterEvent = 1
local GamepassId = 75665424

local function ownsGamepass()
	print(Player.Name,"owns gamepass",GamepassId)
	script.Parent.Check.Visible = true
	
end

if MarketplaceService:UserOwnsGamePassAsync(Player, GamepassId) then
	ownsGamepass()
end

BuyButton.MouseButton1Click:Connect(function()
	local gamepassOwned = MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamepassId)
	if gamepassOwned then
		ownsGamepass()	
	else
		MarketplaceService:PromptGamePassPurchase(Player, GamepassId)
	end
end)


MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, gamepassId, wasPurchased)
	if wasPurchased and Player == player then
		if gamepassId == GamepassId then
			ownsGamepass()
		end
	end
end)

oh ok, let me check it out, will let you know if it works for me

i don’t think firing a remote event to prompt a purchase would matter. I suggest that he would just prompt it from the localscript since it would be easier

May I ask what your ultimate goal here is? What’re you trying to do if the player owns the gamepass? It seems you’re trying to fire a special RemoteEvent to the server. You could easily handle the whole thing on the server instead of going back & forth client-server, server-client.

1 Like

I’m trying to stop the advice once the player has the gamepass, but i’m having problems with this advice because every time I click on the skin to choose it, the same advice appears again

I’m having an error on the output, “Unable to cast Instance to int64”, I just tried making the variable but “UserOwnsGamePassAsync” it appears me an error, I mean an orange underline

Just swap the Player and the GamepassId, I think you put them in the wrong parameters.

1 Like

umm, now it doesn’t let me be the skin selected

You’re trying to be the skin selected but you don’t have anything setup to change your skin… So, what’re you trying to run/fire to change your skin??

1 Like

yes, I have a script inside the server script service, and it set up the character.

here is the code:

local changeEvent = game.ReplicatedStorage:WaitForChild(“ChangePlayerCharacter”)

local charsFolder = game.ReplicatedStorage:WaitForChild(“GamepassSkin”)

changeEvent.OnServerEvent:Connect(function(player,chosenCharacter)
if charsFolder:FindFirstChild(chosenCharacter) then
local newChar = charsFolder:FindFirstChild(chosenCharacter):Clone()
local plrChar = player.Character

	if newChar:FindFirstChild("HumanoidRootPart") then
		newChar.PrimaryPart = newChar.HumanoidRootPart
		newChar:SetPrimaryPartCFrame(plrChar.HumanoidRootPart.CFrame)
	elseif newChar:FindFirstChild("Torso") and not newChar:FindFirstChild("HumanoidRootPart") then
		newChar.PrimaryPart = newChar.Torso
		newChar:SetPrimaryPartCFrame(plrChar.Torso.CFrame)
	end
	if player.Character:FindFirstChild("Animate") then
		local anim = player.Character:FindFirstChild("Animate"):Clone()
		anim.Parent = newChar
	end

	newChar.Name = player.Name
	player.Character = newChar

	local rootPart = newChar:FindFirstChild("HumanoidRootPart") or newChar:FindFirstChild("Torso")
	local plrRoot = player.Character:FindFirstChild("HumanoidRootPart") or player.Character:FindFirstChild("Torso")

	if rootPart and plrRoot then
		rootPart.CFrame = plrRoot.CFrame
	end

	newChar.Parent = workspace
else
	warn("character doesnt exist or something went wrong.")
end

end)

Yeah, you shouldn’t fire RemoteEvents from client to server without checking if the player owns the gamepass/or even item first (on the Server).

1 Like

oh ok, so it would be like this?,

local guiDisabled = MPS:UserOwnsGamePassAsync(Player,ID)

changeEvent.OnServerEvent:Connect(function(player,chosenCharacter)

if not guiDisabled == true then

guiDisabled = false

end