Help with GravityCoil/SpeedCoil Gamepasses

so I was trying to make a gravity coil gamepass with a gui aswell and made a script and I followed many tutorials but every single time it either says:
image
Or one time it just never gave the coil. I need help on how to make a script that works for that and I already have a gravity coil tool but a lot of the tutorials kept the scripts and tools in different places each time so im just not sure at this point but here is my current scripts:


and also

Someone please help me thanks.

Use :PromptGamepassPurchase(player, gamepassId) instead of :PromptProductPurchase on the client.

1 Like

That didn’t really do much this is what happens now:


these are the scripts maybe u can edit them and see if it works not sure:

script.Parent.MouseButton1Click:Connect(function()

game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer, 86737822)

end)

Another one:

local Players = game:GetService("Players")
local MarketPlaceService = game:GetService("MarketplaceService")
local GamepassID = 86737822
local ToolName = "GravityCoil"

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamepassID) then
			script[ToolName]:Clone().Parent = player.Backpack
		end
	end)
end)

and these are the locations of the items I have
image
and another one
image
Please help when you can and if need where to put the things at because these youtube tutorials are all saying different things.

Add another script in ServerScriptService called GamepassManager and put this in:

--//Services
local MarketplaceService = game:GetService("MarketplaceService")

--//Tables
local passFunctions = {}

--//Functions
passFunctions[86737822] = function(player)
	if not player.Character then
		return
	end
	
	local newGravityCoil = script.Parent.Script.GravityCoil:Clone()
	newGravityCoil.Parent = player.Backpack
end

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, purchasedPassId, purchaseSuccess)
	if purchaseSuccess then
		passFunctions[purchasedPassId](player)
	end
end)

This isn’t very optimal though, because you should put your gears in ServerStorage. This will work though.

1 Like

Ok well I followed it and it did work but now I’m trying to make a speed coil one and I made a gamepass manager 2 which im pretty im not supposed to do and I think im supposed to make it inside the other gamepass manager but how would I go by doing that. Here is what i tried:


local passFunctions = {}

passFunctions[87111630] = function(player)
	if not player.Character then
		return
	end

	local newGravityCoil = script.Parent.Script.GravityCoil:Clone()
	newGravityCoil.Parent = player.Backpack
end

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, purchasedPassId, purchaseSuccess)
	if purchaseSuccess then
		passFunctions[purchasedPassId](player)
	end
end)

It’s the same script only the id is the same and I already made the button and script like before but when I try buying the pass it works just doesnt give the item. Could you maybe help me there.

Bump β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž

local MarketPlaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local GravityCoil = script:FindFirstChildOfClass("Tool")
local GamepassId = 87111630

local function CheckIfUserHasGamepass(UserId : number, GamepassId : number) : boolean
	local UserHasGamepass = false

	local Works, HasGamepass = pcall(function()
		return MarketPlaceService:UserOwnsGamePassAsync(UserId, GamepassId)
	end)

	if Works and HasGamepass == true then
		UserHasGamepass = true
	elseif not Works then
		local Attempts = 0

		repeat task.wait(1)
			Works, HasGamepass = pcall(function()
				return MarketPlaceService:UserOwnsGamePassAsync(UserId, GamepassId)
			end)

			Attempts += 1
		until Works or Attempts >= 5

		if Works and HasGamepass == true then
			UserHasGamepass = true
		end
	end

	return UserHasGamepass
end

Players.PlayerAdded:Connect(function(Player)
	local UserHasGamepass = CheckIfUserHasGamepass(Player.UserId, GamepassId)
	
	if UserHasGamepass then
		local ClonedTool = GravityCoil:Clone()
		local ClonedTool2 = GravityCoil:Clone()

		ClonedTool.Parent = Player.Backpack
		ClonedTool2.Parent = Player.StarterGear
	end
end)

MarketPlaceService.PromptGamePassPurchaseFinished:Connect(function(Player, GamepassId, IsPurchased)
	if IsPurchased and GamepassId == GamepassId then
		local ClonedTool = GravityCoil:Clone()
		local ClonedTool2 = GravityCoil:Clone()

		ClonedTool.Parent = Player.Backpack
		ClonedTool2.Parent = Player.StarterGear
	end
end)

What’s your other speed coil id?

The ID for the speed coil is 87111630 as I said previously

Where do I put this? I dont think I would replace the other script since this only has one ID or do I just put this one in the thing I said was gamepasschecker2 or something like that

Also you put the id of the speed coil and then also put gravity coil

Oh maybe I messed up by putting β€œgravitycoil” when it was a speed coil if thats not the issue maybe help thanks

Oh my bad I put β€œgravitycoil” when it was speed coil but if that wasnt the issue please tell me what I could do

You should not be making a new script for it, as there is no need.

Just change your GamepassManager script to this:

--//Services
local MarketplaceService = game:GetService("MarketplaceService")

--//Tables
local passFunctions = {}

--//Functions
passFunctions[86737822] = function(player)
	if not player.Character then
		return
	end

	local newGravityCoil = script.Parent.Script.GravityCoil:Clone()
	newGravityCoil.Parent = player.Backpack
end

passFunctions[87111630] = function(player)
	if not player.Character then
		return
	end

	local newSpeedCoil = script.Parent.MySpeedCoil:Clone() --//Reference your speed coil
	newSpeedCoil.Parent = player.Backpack
end

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, purchasedPassId, purchaseSuccess)
	if purchaseSuccess then
		passFunctions[purchasedPassId](player)
	end
end)

nope still didnt work :confused:


at this point I dont know anymore bruh it just doesnt work. I buy it and it brings me here and btw the speed coil is just called SpeedCoil and the gravity one called GravityCoil.

also now both dont work so if u can please help thanks.

I said to reference your speed coil, if you’re speed coil wasn’t called MySpeedCoil then it wouldn’t have worked. You should check this out for some info:

Also why did you change the clone part? You shouldn’t be changing the :Clone because it already worked.

I messed up what I meant to say is I changed the newSpeedCoil part to SpeedCoil didn’t work, ive tried making the MySpeedCoil to SpeedCoil still didnt work which i dont know how that would fix it when the gravity coil name was right and still didnt work so I just dont know

Is there anything else I have to make changes to because it just doesnt work.