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

How to make a vehicle only driveable by people with a certain gamepass?

Asked by 4 years ago

Question 1: How do i make a certain team open something Question 2: How to make a vehicle only driveable by people with a certain gamepass?

I am making a border game and i want a certain team to open the border not like anyone could open the border. So i need help on that.

Second question is how do i make a car only driveable by the people who owns the gamepass. Also need help on this.

1 answer

Log in to vote
0
Answered by
Pupppy44 671 Moderation Voter
4 years ago
Edited 4 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

You can use UserOwnsGamePassAsync. I didn't try this:

function Change() -- The function
if workspace.Seat.Occupant ~= nil then -- Checks if the Occupant is not nil aka. nothing
local Player = game:GetService("Players"):FindFirstChild(workspace.Seat.Occupant.Parent.Name)
if Player then -- If "workspace.Seat.Occupant.Parent.Name" is found in game.Players
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, 1234) then -- Checks if the player has the gamepass 1234
print("Has gamepass") -- Prints
else
workspace.Seat.Occupant.Jump = true -- Jumps the player so the player cannot sit on it.
end
end
end
end


workspace.Seat.Changed:Connect(Change) -- Using the Changed event to detect a new occupant

Sorry mod, added comments

0
where to i put the gamepass id? Xxgamerrobllox3 -23 — 4y
0
Line 05 - game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, GamePassID) Xx_XSanderPlayXx 160 — 4y
0
thx Xxgamerrobllox3 -23 — 4y
0
If it works, please mark it as answered :) Pupppy44 671 — 4y
0
This is really weird but i tried everything and the script does not work Xxgamerrobllox3 -23 — 4y
Ad

Answer this question