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

Gamepass script not working?Your title should be specific! Describe your problem concisely.

Hello, I have a testing script that is supposed to prompt you with a marketplaceservice prompt then you can drive it. But it doesnt work. My friend could drive the car just fine without the gamepass.

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
 
local gamePassID = 10098895  -- Change this to your game pass ID
 
local function onPlayerAdded(player)
 
	local hasPass = false
 
	-- Check if the player already owns the game pass
	local success, message = pcall(function()
		hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
	end)
 
	-- If there's an error, issue a warning and exit the function
	if not success then
		warn("Error while checking if player has pass: " .. tostring(message))
		return
	end
	if hasPass == false then
		print(player.Name .. " does not own the game pass with ID " .. gamePassID)
		script.Parent.ClickDetector.MouseClick:connect(function(player)
			MarketplaceService:PromptPurchase(game.Players.LocalPlayer, 10098895)
		end)
	end
 
	if hasPass == true then
		print(player.Name .. " owns the game pass with ID " .. gamePassID)
local speed = game.Workspace.Values.ElectricPower
local tuneindicator = script.Parent.Electric_shock
script.Parent.ClickDetector.MouseClick:connect(function(player)
	workspace.P406.Shell.Velocity = workspace.P406.Shell.CFrame.LookVector * speed.Value
	if speed.Value > 100 then
		tuneindicator:Play()
	end
end)
	end
end
 
-- Connect "PlayerAdded" events to the "onPlayerAdded()" function
Players.PlayerAdded:Connect(onPlayerAdded)

1 answer

Nvm I fixed it. i JUST had to remove the

  if hasPass == false then

line.

2 comments

0

no, i wanted to help you

0

Nice. :PP

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