The problem I am having is that some vehicles will have to be purchased via gamepass
while the others(free) will not be purchasable but available to everyone
but the script i currently have errors out and says Argument 2 missing or nil
local SpawnVehicle = function(Player , Vehicle)
if not MarketplaceService:UserOwnsGamePassAsync(Player.UserId , tonumber(Vehicle.Parent.Parent.Gamepass.Value)) then -- Detects if player has the gamepass
MarketplaceService:PromptGamePassPurchase(Player , tonumber(Vehicle.Parent.Parent.Gamepass.Value))
return
end
if not Vehicle.Parent.Parent.allowed.Value then -- detects if allowed value is false, if so stops script
return
end
print(Player)
print(tonumber(Vehicle.Parent.Parent.Gamepass.Value))
local Character = Player.Character or Player.CharacterAdded:Wait()
local PlayerFolder = Folder(Player.UserId , MainFolder)
PlayerFolder:ClearAllChildren()
local New = Vehicle:Clone()
print("spawning vehicle")
New:SetPrimaryPartCFrame(Character:WaitForChild("HumanoidRootPart").CFrame*CFrame.new(10,0,0))
New.Parent = PlayerFolder
end
when this part of the script is commented out the free vehicles are spawnable
--[[if not MarketplaceService:UserOwnsGamePassAsync(Player.UserId , tonumber(Vehicle.Parent.Parent.Gamepass.Value)) then -- Detects if player has the gamepass
MarketplaceService:PromptGamePassPurchase(Player , tonumber(Vehicle.Parent.Parent.Gamepass.Value))
return
end]]
if not Vehicle.Parent.Parent.allowed.Value then -- detects if allowed value is false, if so stops script
return
end
but when this part of the script is commented out the gamepass one is purchaseable
if not MarketplaceService:UserOwnsGamePassAsync(Player.UserId , tonumber(Vehicle.Parent.Parent.Gamepass.Value)) then -- Detects if player has the gamepass
MarketplaceService:PromptGamePassPurchase(Player , tonumber(Vehicle.Parent.Parent.Gamepass.Value))
return
end
--[[if not Vehicle.Parent.Parent.allowed.Value then -- detects if allowed value is false, if so stops script
return
end]]