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

how to make a double jump gamepass script?

Hello. I have been trying a lot to write a double jump gamepass script but still couldn't figure it out. There also isn't any helpful videos for it cuz everyone explains the double jumping part but not the gamepass part. Can someone give me an example of a double jump gamepass script?

2 answers

✓ Accepted answer

The link that the other guy sent explains it so if you say you know how to make a double jump script you just need to combine it. You need to use MarketplaceService as it has function that allows you to check if UserOwnsGamePassAsync. This is all you need, in script you would make it look like this

local MarketplaceService = game:GetService('MarketplaceService')
local Players = game:GetService('Players')

local GAMEPASS_ID = 5 + 2 -- your gamepass id, on the wiki site it explains how to get it, copy it from the gamepass link

local function OnGamerAdded(Gamer)
	--/Sometimes they gamers leave right after joining
	--\and in rare cases it can error, if no-one plays your
	--\game you will never experience such a problem
	--\but trust me, it happens. In cases where i send errors
	--\to discord it is annoying so preventing this is cool.
	if not (Gamer) then
		return
	end

	local Success, Response = pcall(
		MarketplaceService.UserOwnsGamepassAsync,
		MarketplaceService,
		Gamer.UserId,
		GAMEPASS_ID
	)

	if (Success) then
		if (Response) then
			print('Gamer owns the gamepass')
		else
			warn('Gamer does not own the gamepass!')
			Gamer:Kick('o')
		end
	else
		warn(('Failed to check if gamer has gamepass because: %s'):format(Response))
	end
end

Players.PlayerAdded:Connect(OnGamerAdded)

This will just print if the user has or has not gamepass, Response variable is a bool representing it. I wrapped the function into a pcall because if roblox services are down or any other problem occurs during the function, it will break this scope which you don't want to. pcall returns 2 values, Success (If the function did not error) and error (Error that happened IF the function did error, else nil). In this case Response is what UserOwnsGamepassAsync returns which is bool because if the function returns something, return is before the error message and after the Success so if the function Would error, Response would be the error because the function would not return anything because it broke. You see i called pcall with 4 arguments, last 2 are because what UserOwnsGamepassAsync requires while the other 2 are the function to pcall and the second is self because you usually call this function with : while in this situation you can't so you need to replace self with something, in this case it's the MarketplaceService itself as it's function of it.

This will only check if user has pass once when he joins because i don't see your case so i can't make better mechanic for it but if you want him to buy the pass in the game for example, you would use MarketplaceService:PromptGamePassPurchase and then use Marketplace.PromptGamePassPurchaseFinished event which fires when you click ok or cancel when the buy popup popups. And in the event you could give the gamer the double jump.


Here are all the sources you would need for that.

pcalls

String Formatting

self

1 comment

0

thank you so much. I understood it now

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