Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to add a gamepass function to a spawn script? [closed]

Asked by 4 years ago

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!

Closed as Not Constructive by youtubemasterWOW

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by
imKirda 4491 Moderation Voter Community Moderator
4 years ago

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.

Ad