Gamepass not giving me anything for buying it!

Do it locally which is preferred for most people. Once you’ve checked locally that they own the game pass, send a remote event through the server, and give the player the tool.

did you remove Tool variable?

30 ch ars

It randomly deleted the variable?!?!?!? I think I fixed it now. Let me check.

It did not work. No tool was given to me.

Do it locally, I can hep you if you want.

did you test purchase it?

30 ch ars

Yes, do I have to actually purchase it?

no, you do not need to purchase the gamepass.

Sure! I’ll send the model over if you can show me how to do it locally.

Alright, send it. I’ll take a look.

You need to use ProcessReceipt for that.

UserOwnsGamePassAync will check if the player owns the game pass once when they join the game (in your case).

That’s for developer products, this is a gamepass.

Alright, working on it right now.

Instead of cloning the tool multiple times, just use StarterGear, also use PromptGamePassPurchaseFinished to detect if the player buys the gamepass.

local MarketPlaceService = game:GetService("MarketplaceService")

local GamepassId = 20286552
local Tool = script.Darkheart

function Get(Player)
	Tool:Clone().Parent = Player.StarterGear
	Tool:Clone().Parent = Player.Backpack
end


MarketPlaceService.PromptGamePassPurchaseFinished:Connect(function(Player, Id, Bool)
	if Bool and Id == GamepassId then				Get(Player)			end
end)
game:GetService("Players").PlayerAdded:Connect(function(Player)
	local Success, Has = pcall(function()
		return MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, GamepassId)
	end)
	print(Success, Has)
	if Success and Has then					Get(Player)
	elseif not Success then					print("Error:", Has)
	end
end)

if Has gives false, it means that you simply don’t have the gamepass

Oh, I thought he was talking about a dev product.

In that case, if you’re purchasing the game pass directly from your game via a Prompt, you will have to use PromptGamePassPurchaseFinished. UserOwnsGamePassAsync in your script will only check if the user owns the game pass upon joining the game.

Also, putting it in a while loop will still not update it due to Roblox’ caching behaviour.

Additionally, PromptGamePassPurchaseFinished has a parameter to check if the game pass was purchased. If it returns true, grant the player the tool.

Alright, I got it working. It’s really simple.

Put this code inside of local script in startergui:


if not game:IsLoaded() then
	game.Loaded:Wait()
end
if not game.Players.LocalPlayer:HasAppearanceLoaded() then
	repeat wait() until  game.Players.LocalPlayer:HasAppearanceLoaded() == true
end

local Market = game:GetService("MarketplaceService")
local GamePassId = 20246474
local RemoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local OwnsGamePass = Market:UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId, GamePassId)


if OwnsGamePass == true then
	RemoteEvent:FireServer(GamePassId)
end

then in serverscript service, make a script and put this code inside:

local RemoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")


RemoteEvent.OnServerEvent:Connect(function(plr, Id)
	local OwnsGamePass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId, Id)
if OwnsGamePass == true then
	if plr.Character then
		local Tool  = game.ReplicatedStorage:WaitForChild("Darkheart")
		local Clone = Tool:Clone()
		if Tool ~= nil and Clone ~= nil then
		Clone.Parent = plr.Backpack
		end
	else
		return
		end
	end
end)
end)

I recommend not doing this since exploiters could give themselves the tool.

1 Like