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

How can I make a vehicle only drivable by people with a gamepass?

I'm making a jeep gamepass in my game and I can make the gamepass owner only area where they get the vehicle but when they drive it out of that area somebody could steal it. I need a fast answer.

1 answer

✓ Accepted answer

Put this in a Script in the VehicleSeat

local GamePassService = game:GetService("GamePassService")
local passId = 0000000 -- change this to your game pass ID
local vehicleSeat = script.Parent
 
vehicleSeat:GetPropertyChangedSignal("Occupant"):Connect(function()
    if vehicleSeat.Occupant then
        local player =
            game.Players:GetPlayerFromCharacter(vehicleSeat.Occupant.Parent)
        if player and GamePassService:PlayerHasPass(player, passId) then
            vehicleSeat.Disabled = false
        else
            vehicleSeat.Disabled = true
        end
    end
end)

1 comment

0

THANK YOUUUUUU

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