i made this gut, but if i buy gamepass it can be purchased more times. i tryed fix it with another text button named purchased but it didnt worked too i think it cant find it in marketplaceservice and it can be purchased again. my script in serverscriptservice

local market = game:GetService("MarketplaceService")
local gamepassID = 14681672

market.PromptGamePassPurchaseFinished:Connect(function(player, purchasePassId, purchaseSuccess)
	if purchaseSuccess == true and purchasePassId == gamepassID then
		player.Character.Humanoid.WalkSpeed = 40
		game.StarterGui.GamepassShop.GamepassesFrame.MoneyGamePass.Purchased.Visible = true
	end
end)

and this is in my gamepass gui

local market = game:GetService("MarketplaceService")
local gamepassID = 14681672
local player = game.Players.LocalPlayer

local function promptPurchase()
	local hasPass = false
	
	local success, message = pcall(function()
		hasPass = market:UserOwnsGamePassAsync(player.UserId, gamepassID)
	end)
	
	if hasPass == true then
		wait(5)
		script.Parent.Purchased.Visible = true
		player.Character.Humanoid.WalkSpeed = 40
	end
end

local function promptPurchased()
	local hasPass = false

	local success, message = pcall(function()
		hasPass = market:UserOwnsGamePassAsync(player.UserId, gamepassID)
	end)

	if hasPass == true then
		script.Parent.Purchased.Visible = true
		player.Character.Humanoid.WalkSpeed = 40
	else
		game:GetService("MarketplaceService"):PromptPurchase(player, gamepassID)
	end
end

script.Parent.Purchase.MouseButton1Click:Connect(promptPurchased)
game.Players.PlayerAdded:Connect(promptPurchase)

4 comments

0

This is a Roblox bug, you don't actually buy it multiple times but it still gets prompted a few times, to fix this you have to set the player in a table as bought gamepass and then stop the script when a player who bought the gamepass is in the list

0

How to stop IT? I clicked purchase And if i clicked again it was purcharsed again... :(

0

I don't think you actually bothered to read his comment. For the sake of summarization, use a table that will contain those who have purchased the gamepass.

0

How?