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

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

Asked by 6 years ago

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

Log in to vote
0
Answered by 6 years ago

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)
0
THANK YOUUUUUU Farmerperson 6 — 6y
Ad

Answer this question