How would I make owner only cars?

Hello.
I have made these basic cars, that use a vehicle seat and some parts.

How would I make the cars so that only people who have a gamepass can use them?
image
image

2 Likes

This should work but Im not sure because I used this a long time ago.

local GamepassID = 16071233 --your id here
local MarketplaceService = game:GetService("MarketplaceService")


script.Parent.ChildAdded:connect(function(child)
    if child.Name == "SeatWeld" then
        local Player = game.Players:GetPlayerFromCharacter(script.Parent.SeatWeld.Part1.Parent)
		if not MarketplaceService:UserOwnsGamePassAsync(Player.userId, GamepassID) then
			print("not Allowed")
            wait(0.00001)
            child:Destroy()
			child.Part1.Parent.Humanoid.Jump = true
		else
			print("allowed")
        end
    end
end)

Put this inside the Seat as a Script.

Use an attribute or StringValue and set the owner’s name to its value. If the occupant is not the owner, kill them or whatever

Gamepass only cars if I understood correctly?

Add a script in the Vehicleseat in this case and basically do something like this

  • Get the seat instance and put it in a variable
  • Use GetPropertyChangedSignal on the Occupant of the seat and connect it to an event
  • Get the humanoid via the Occupant of the seat, is the Occupant nil?
  • If it isn’t nil, get the player instance from the Occupant by doing game.Players:GetPlayerFromCharacter(human.Parent) where human is the occupant of the seat
  • Use UserOwnsGamePassAsync like how @ShyFlooo mentioned and if they don’t own the gamepass, make them jump off or kill them, depending on what you wanna do

I wouldn’t recommend using a premade script as it doesn’t help you improve your scripting skills

2 Likes

check out this video: Gamepass Vehicle Seat for Roblox Studio - YouTube