Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I give a player a tool after purchasing a game pass in-game?

I would like to set up an in-game gamepass purchase that gives you the tool after buying the game pass in-game. This would be very convenient for players purchasing game passes, because implementing the current script I have right now would require them to wait for the server to restart.

Here is what I have

local Id = 626438744 --Change this number to your Game Pass ID.

script.Parent.ClickDetector.MouseClick:connect(function(player)
	game:GetService("MarketplaceService"):PromptPurchase(player, Id)
end)

Help would be much appreciated.

2 answers

local Id = 626438744
local Gamepass = game:GetService("GamePassService")
local 
game.Players.PlayerAdded:connect(function(plr)

	if Gamepass:PlayerHasPass(player, Id) then
		game.LOCATIONOFTOOL.Toolname:clone().Parent = plr.Backpack
		game.LOCATIONOFTOOL.Toolname:clone().Parent = plr.StarterGear
	





end)

This code should work.

2 comments

0

Not working.

0

oh rip forgot to remove that "Local" sorry

local Id = 626438744
local Gamepass = game:GetService("GamePassService")
local tool = game.ServerStorage:WaitForChild("TOOLNAME") --change tool name and make sure its in serverstorage

game.Players.PlayerAdded:connect(function(plr)

    if Gamepass:PlayerHasPass(player, Id) then
        tool:Clone().Parent = plr.Backpack
        tool:Clone().Parent = plr.StarterGear
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.