How to make a gamepass radio for A-Chassis?

I want to make a radio gamepass for A-Chassis vehicles so that people don’t abuse it.

What I want to do:
That when you get in the vehicle there is a button to open the radio, if you don’t have the gamepass it asks you to buy the gamepass and if you have it it opens the GUI where you can put any song ID.

I would just create a separate gui that shows up whenever someone sits down inside of the seat, not A-Chassis related but just simply a recommendation.

Do you have a gui made already?

If you want to make a button that will prompt a purchase for a gamepass, first make the gamepass, then copy the line of numbers in the search bar. Then in your game, make the buttons and everything. Then, insert a LocalScript inside of the button and name it whatever you want. Finally, insert the following code into your LocalScript:

local mps = game:GetService("MarketplaceService")
local passId = 0 -- your gamepass id here

script.Parent.MouseButton1Click:Connect(function(player)
	mps:PromptPurchase(player,passId)
end)

This will prompt the purchase and ask the player if they want to buy it or not.

local players = game:GetService("Players")
local marketplace = game:GetService("MarketplaceService")
local server = game:GetService("ServerStorage")
local gui = server.ScreenGui --Example.

local seat = script.Parent

local gamepassId = 0 --Change to ID of gamepass.

seat:GetPropertyChangedSignal("Occupant"):Connect(function()
	local humanoid = seat.Occupant
	if humanoid then
		local character = humanoid.Parent
		local player = players:GetPlayerFromCharacter(character)
		if player then
			local success1, result1 = pcall(function()
				return marketplace:UserOwnsGamePassAsync(player.UserId, gamepassId)
			end)
			
			if success1 then
				if result1 then
					print(result1)
					local playerGui = player.PlayerGui
					local screenGui = playerGui:FindFirstChild(gui.Name)
					if screenGui then
						return --Prevents duplicate GUIs.
					end
					screenGui = gui:Clone()
					screenGui.Parent = playerGui
				elseif not result1 then
					print(result1)
					local success2, result2 = pcall(function()
						return marketplace:PromptGamePassPurchase(player, gamepassId)
					end)
					
					if success2 then
						if result2 then
							print(result2)
						end
					else
						warn(result2)
					end
				end
			else
				warn(result1)
			end
		end
	end
end)

Here’s a sample script to get you started, it needs to be a server script placed inside the seat/vehicle seat instance.

You’ll need a “ScreenGui” instance parented to the “ServerStorage” folder.

2 Likes