Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Gamepass only vehicle script seems not to be working, please help if you can?

This is my gamepass only vehicle script that kills the player and prompts purchase when the player doesn't have the gamepass. I assume the kill and prompt purchase part doesn't seem to be working. The script is inside the driver's seat of the vehicle.

id = 6528838
promptpurchase = true
game.Players.RespawnTime = 0
gps = game:GetService("GamePassService")
local player = game.Players.LocalPlayer

script.Parent.Changed:connect(function(prop)
	if prop == "Occupant" and script.Parent.Occupant then
		if gps:UserOwnsGamePassAsync(game.Players:GetPlayerFromCharacter(script.Parent.Occupant.Parent), id) then
		print("User in car has gamepass.")	
		else
            script.Parent.Occupant:TakeDamage(100)
			if promptpurchase == true then
            game:GetService("MarketplaceService"):PromptGamePassPurchase(player, id)
            
	         end
	     end
	 end
   end

Please help if you can, it's annoying that this doesn't seem to work.

2 answers

local seat = script.Parent -- Put inside your seat
local assetid = 190700972 -- the gamepass's id.

seat.Changed:connect(function()
	if seat.Occupant and not game:GetService("MarketplaceService"):PlayerOwnsAsset(game.Players:GetPlayerFromCharacter(seat.Occupant.Parent),assetid) then
		local player = game.Players:GetPlayerFromCharacter(seat.Occupant.Parent)
		seat.Occupant.Jump = true
		game:GetService("MarketplaceService"):PromptPurchase(player,assetid,false,Enum.CurrencyType.Robux)
	end
end)

Try this, might not work. May have some errors. Old script I used.

1 comment

0

I've tried that script before I believe, and I edited it to make it work with the new gamepasses, and it doesn't work. That's for the help though. (still looking for a solution)

For starters, use :BreakJoints(), it is easier and quicker than :TakeDamage. 2. It should be PlayerHasPass or PlayerOwnsAsset, not UserOwnsGamePassAsync... 3. Haven´t coded for a while, but I´m pretty sure you need to specify ¨Occupant¨ as a variable.

This discussion is preserved as it was. New answers, comments, and votes are closed.