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 make a Gamepass that gives the player a custom model tool?

local item = game.ServerStorage.SuperExplosivePowerRocketLauncher

game.Players.PlayerAdded:connect(function(plr)
	if game:GetService("MarketplaceService"):PlayerOwnsAsset(plr,4429257) then
local a = item:Clone()
 a.Parent = plr.Backpack
  else
        print(plr.Name .. " doesn't have the game pass...")
    end
end)

I use that code and it says I do not own the Gamepass whenever I test it. Same with when I make the game public and play it (I do not get the SuperExplosivePowerRocketLauncher) I have tried so many scripts but none of them worked. I have tried the PlayerHasPass thing but nothing works. I double checked if the Gamepass was in my possesion, and it was. I need this resolved so I can continue developing my game place.

1 comment

1 answer

Let's make a few slight modifications. The player's backpack is reset every time they respawn. a is a useless variable name, so we can rename it to something useful. RBXScriptSignal:connect() is deprecated, so we will use RBXScriptSignal:Connect(). We will use the new method to check whether players own gamepasses.

local marketplaceService = game:GetService("MarketplaceService")

local gamePassId = 2838282
local gamePassTool = game.ServerStorage.SuperExplosivePowerRocketLauncher

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function()
		if not marketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassId) then
			return
		end

		gamePassTool:Clone().Parent = player.Backpack
	end)

	
end)

Alternatively, we could use player.StarterGear.

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