I've been trying to make a game pass for my game that on spawn, you would get a different piece of gear. I have been looking at different tutorials and websites, but none of them told me how to add a game pass that gives random gear on spawn. Can you please help me?
COMMUNITY QUESTION
How do I make a gamepass that gives random gear on spawn?
1 answer
Create a folder in ServerStorage called Tools, put the tools you would like to give to a player, then make a script in the workspace and put this in it
local MarketPlaceService = game:GetService("MarketplaceService") --Getting marketplaceservice
local players = game:GetService("Players") --Getting the players
local tools = game.ServerStorage.Tools:GetChildren --Getting the tools
if tools.nil == true then
local newfolder = Instance.new("Folder",ServerStorage)
newfolder.Parent = game.ServerStorage
newfolder.Name = "Tools" --Creates the folder for you if you don't have it :)
end
local gamepassid = "PUTGAMEPASSIDHERE" --Replace PUTGAMEPASSIDHERE with your gamepass id
function spawned(player)
local HasGamepass = false --Says you don't have the gamepass
local success, message = pcall(function()
HasGamepass = MarketPlaceService:UserOwnsGamePassAsync(player.userid, gamepassid)
end)
if not success then
warn("Checking for the game pass, please wait..."..tostring(message))
return
end
if HasGamepass == true then
local randomtool = game.ServerStorage.tools[math.random(1, #tools)]
local toolclone = randomtool:Clone()
toolclone.Parent = player.Backpack
end --Gives a random tool from the folder if you own the gamepass
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
Spawned(player)
end)
end)
Players.PlayerSpawned:Connect(Spawned)
Also, scripting helpers is for help with code, not request code. Let me know if this works!
1 comment
0
Thank you for trying @MediaHQ , but this code does not work!
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Well, maybe if there was an attempt script, then maybe more people will help, this has a risk of being deleted for not "being constructive"
Here is a script that I am using. It gives specific tools. I am still new to scripting, so I don't know how to make the gear switch on spawn.
game.Players.PlayerAdded:connect(function(player) local mkps = game:GetService("MarketplaceService") local ss = game.ServerStorage repeat wait(0.1) until player.Backpack repeat wait(0.1) until player.StarterGear if mkps:UserOwnsGamePassAsync(player.UserId, GAMEPASSID) then ss.Sword:Clone().Parent = player.Backpack ss.Sword:Clone().Parent = player.StarterGear end end)