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

How to add a gamepass function to a spawn script?

So basically I wand to add a gamepass function to this script so when i someone buys it they can press the image button spawn the Vehicle:

script.Parent.MouseButton1Click:connect(function(GetCar)
		Mod = game.ServerStorage.HoverJeep     
		clone = Mod:clone()
		clone.Parent = workspace
		clone:MakeJoints()
	end)

All I need now is the gamepass function but I don't Know How To Add It!

1 answer

✓ Accepted answer

You are using a local script right? If so then:

local market = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
local ID = 12345678 -- your id
script.Parent.MouseButton1Click:connect(function(GetCar)
	if market:UserOwnsGamePassAsync(player.UserId, ID) then
      Mod = game.ServerStorage.HoverJeep    
      clone = Mod:clone()
      clone.Parent = workspace
      clone:MakeJoints()
		end
    end)

it checks if player has the gamepass and if yes then it does the function.

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