How do I create a gamepass spawner?

  1. What do you want to achieve? Keep it simple and clear!
    Trying to achieve making a gamepass such as a Yacht that will spawn in water when a player runs the command !spawn and spawns a yacht on the water.

  2. What is the issue? Include screenshots / videos if possible!
    I’m trying to figure how where to start as I’m fairly still new to making gamepasses and in the last 12 hours I have managed to make two successful gamepasses which work thankfully.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I looked around on the Developer Hub however I did not find anything relevant. However I watched some YouTube videos on how to develop and make Gamepasses to get some more knowledge.

4 Likes

First of you would want to use the .Chatted event to detect the command and then use MarketPlaceService to check if the player owns the gamepass. A script could look something like this:

local MS = game:GetService('MarketPlaceService')
local PassId = 12345 -- gamepass ID here
game.Players.PlayerAdded:Connect(function(plr) -- player added
plr.Chatted:Connect(function(msg) -- player chatting
if string.lower(msg) == '!spawn' and MS:UserOwnsGamepassAsync(plr.UserId, PassId) then -- string.lower removes all caps so it will still work if the player says spawn and uses caps
-- spawn script here
end)
end)

I would suggest reading the api for MarketPlaceService as well just so you can get a good understanding of it!

3 Likes

I came across a Youtube video while browsing on How to make car spawner. but modified it so it would spawn the boat I want. Boat model is in ServerStorage
Script is this
script.Parent.MouseButton1Click:connect(function(GetBoat)
Mod = game.ServerStorage.Boat
clone = Mod:clone()
clone.Parent = workspace
clone:MakeJoints()
end)
Since this now works and successfully spawns a Boat in the water How can I modify this so if someone was to purchase the Boat Gamepass it spawns it in for them after they click the button?

1 Like