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

need some help because i'm a starter?

I need to know how to know the code/module of my car/vehicle? (see in this script line 6)

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

2 comments

0

Dude, try watching a tutorial or something before asking here, if that doesn't work than come back here and ask

0

@TheStageGuyYT I already searched and watched for hours and I didn't help so I post it here

1 answer

You need to define the player as the first parameter of UserOwnsGamepassAsync()

So you'd want something like:

local MPS = game:GetService('MarketplaceService')
local Players = game:GetService('Players')
local gamepassId = https://tenor.com/view/gullible-gif-23847583

Seat:GetPropertyChangedSignal('Occupant'):Connect(function()
	if Seat.Occupant ~= nil then
		local Player = Players:GetPlayerFromCharacter(Seat.Occupant.Parent)
		if Player then
			if MPS:UserOwnsGamepassAsync(Player, gamepassId) then
				-- do stuff
			else
				-- no gamepass, prompting purchase
				MPS:PromptGamepassPurchase(Player, gamepassId)
			end -- gamepass check
		end -- check if player is sitting on it (incase of npcs)
	end -- check if not nil
end) -- changedSignal

2 comments

0

this is such a sad answer

0

It didn't helped my I need to know in my script line 6 how can i know the module/code of the car

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