Does anybody know how I could make it so the script below also allows certain users access to it.
So basically what I want to be able to do is put peoples usernames into the script then it will allow them to drive the vehicle without owning the gamepass.
(mostly to be used to allow staff access without having to pay and for free access giveaways on discord)
The script I currently use (fully works)
local MarketplaceService = game:GetService("MarketplaceService")
local id = 0000000000
local seat = script.Parent
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
local human = seat.Occupant
if human then
local player = game.Players:GetPlayerFromCharacter(human.Parent)
if not player then return end
if MarketplaceService:UserOwnsGamePassAsync(player.UserId,id) then
print("Player owns the gamepass")
else
print("Player does not own the gamepass")
human:TakeDamage(100)
script.Parent.Parent:Destroy()
end
end
end)
if Market:OwnGamePass() or userIds[player.UserId] then
The code I provided isn’t ready-to-use or working. It is just an example PSA: Always use players UserIds instead of usernames since userId is permanent and username can be changed
local allowUsers = {
"UserName",
"OtherUserName",
"NameUser"
}
local MarketplaceService = game:GetService("MarketplaceService")
local id = 0000000000
local seat = script.Parent
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
local human = seat.Occupant
if human then
local player = game.Players:GetPlayerFromCharacter(human.Parent)
if not player then return end
local allow = false
for v, idName in pairs(allowUsers ) do
if player.Name == idName then
allow = true
end
end
if MarketplaceService:UserOwnsGamePassAsync(player.UserId,id) or allow then
print("Player owns the gamepass")
else
print("Player does not own the gamepass")
human:TakeDamage(100)
script.Parent.Parent:Destroy()
end
end
end)