How should I make a gamepass that grants a tool (gear)?

Hi there, noob dev here again. Like the title says, I have a tool that I want to appear in the starterpack of players who have the pass.

8 Likes

If you ready have a script that checks whether or not a player has the gamepass, then add this line.

local tool = (define here the tool):Clone()
tool.Parent = player.StarterGear

If you want to put it on starterpack.

If you do not count with a script, check this document: Passes | Documentation - Roblox Creator Hub

2 Likes

Shouldn’t that be in a local script? If not then everyone else would also get the tool

2 Likes

It should be on a server-sided script.
You would have to define the player based on events for example:

game.Players.PlayerAdded:Connect(function(player)
--code here
end)
3 Likes

Here’s some pseudocode I randomly wrote up, it should work. Just input the path for the tool you want the player to receive and also input the gamepass ID. :slight_smile:

local mps = game:GetService("MarketplaceService")
local gamepass_ID = 0 --//Your gamepass ID here
local tool = --//Input the path to a tool
game.Players.PlayerAdded:Connect(function(player)
local has_pass = mps:UserOwnsGamePassAsync(player.UserId, gamepass_ID)
player.CharacterAdded:Connect(function()
if has_pass then
tool:Clone().Parent = player.Backpack
end
end)
end)
5 Likes
local mps = game:GetService("MarketplaceService")
local gamepass_id = 0 --enter the gamepass asset id here
local plrs = game:GetService("Players")

game.Players.PlayerAdded:Connect(function(player)
		if mps:UserOwnsGamePassAsync(player.UserId , gamepass_id) then
			game.ServerStorage.ToolExample:Clone().Parent = player.Backpack
			game.ServerStorage.ToolExample:Clone().Parent = player.StarterGear
		end
end)

this is a script that is inside ServerScriptService that i use that gives you the gear that is inside ServerStorage. not only does it give you the gear, but it also puts it in the players StarterGear, making it to where the gear will be readded to the player’s backpack everytime the player respawns.

22 Likes

Alright, I’ll try this out. Thank you.

5 Likes