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

Car gamepass that kicks you out and that pop up the gamepass to buy it?

Can someone help my I made a car gamepass but it don't know how to code the kicker and the pop up?

I can use this 1 but i don't know how to find the "code/module of my car" can you help me guys?

local MarketplaceService = game:GetService("MarketplaceService")
Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
    if MarketPlaceService:UserOwnsGamePassAsync(27137596) then
         --whatever vehicle code/module
    else
        Seat.Occupant.Sit = false
    end
end)

1 answer

The only thing you need is, make a function(which the service already has it) to pop up the claim to buy the gamepass called :PromptGamePassPruchase(player, id); copy & paste this inside you script(I added some changes to it)

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService('Players')
local id = 27137596
Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
    if MarketPlaceService:UserOwnsGamePassAsync(id) then
         --whatever vehicle code/module
    else
        if Occupant:FindFirstChild('Humanoid') then -- verifies if the occupant has a humanoid(if is a player)
             local plr = Players:GetPlayerFromCharacter(Occupant) -- gets the player from the occupant of the seat(character)
            MarketplaceService:PromptGamePassPurchase(plr, id) -- prompts the gamepass claim to purchase it.
            Seat.Occupant = nil
        end
    end
end)

3 comments

0

thank you so much, you are a legend

0

can you say me how to know the module/code of my car because i don't know? Im a beginner in lua for roblox. And im very bad at scripting

0

You should put whatever starts the function of the car, but I'm not really sure what should be there because I don't where is you module in your game and how it works.

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