Gear Gamepass Issues (Speed and Gravity coils)

So today…followed many different tutorials, done a ton of research on threads here and on Youtube too.

I created a simple button gui, stuck to basic scripts to award the player a speed or gravity coil in game and it fails to work.

Players are able to purchase the game pass, however it doesn’t award them the tool (includes when re-joining a server).

Current code:

	local GamePassId = 19711172

	game.Players.PlayerAdded:Connect(function(player)

		if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamePassId) then

			game.ServerStorage.Gravitycoil:Clone().Parent = player:WaitForChild("Backpack")
			game.ServerStorage.Gravitycoil:Clone().Parent = player:WaitForChild("StarterGear")
		end

Can anyone help me?

1 Like

you forgot an end) in the playeradded function

2 Likes

Fixed that, however still no speed coil (From Server Storage) is given to the player. (Testing in studio at the moment).

try using game:GetService(“ServerStorage”)

and make sure the tool name is correct

and is there any errors youre getting?

1 Like

Tool name is correct, i’ll try game:GetService(“ServerStorage”)
Zero errors which is the very confusing part, i’ve been trying to do this all day

i see you dont have a marketplaceservice variable

Yeah, you need to create a val for MarketPlaceService.

how do i go about adding a mps variable?

local MarketPlaceService=game:GetService(“MarketPlaceService”)

1 Like

local MarketPlaceService = game:GetService(“MarketPlaceService”)

This service is for like purchasing gamepasses in-game, dev products in game, etc.

It also allows you to check if someone has purchased anything.

3 Likes
	local GamePassId = 19711172

game.Players.PlayerAdded:Connect(function(player)
	
end)

		if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamePassId) then

			game.ServerStorage.Gravitycoil:Clone().Parent = player:WaitForChild("Backpack")
			game.ServerStorage.Gravitycoil:Clone().Parent = player:WaitForChild("StarterGear")
		end

ServerScriptService.Script:8: attempt to index nil with ‘UserId’ - Server - Script:8 (Seems to be an error).

Gravity coil tool, is still not given after purchasing in testing

local MarketPlaceService = game:GetService("MarketplaceService")
	local GamePassId = 19711172

game.Players.PlayerAdded:Connect(function(player)
	
end)

		if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamePassId) then

			game.ServerStorage.Gravitycoil:Clone().Parent = player:WaitForChild("Backpack")
			game.ServerStorage.Gravitycoil:Clone().Parent = player:WaitForChild("StarterGear")
		end

Sorry, the scripts always had it at the top - somehow through pasting it cropped it out

1 Like

Like this:

local MPS = game:GetService(“MarketPlaceService”)

local SS = game:GetService(“ServerStorage”)

local GamePassId = 19711172

game.Players.PlayerAdded:Connect(function(player)

if MPS:UserOwnsGamePassAsync(player.UserId, GamePassId) then

                    local gravitycoil = SS.Gravitycoil
                    local clone = gravitycoil:Clone()
                    player:WaitForChild("Backpack")
                    clone.Parent = player.Backpack
                    local gravitycoil = SS.Gravitycoil
                    local clone = gravitycoil:Clone()
                    player:WaitForChild("StarterPack")
                    clone.Parent = player.StarterPack

	end
 end)
P.S.

Sorry if my code is rusty.

Have the If statement inside game.Players.PlayerAdded.

add that in below for example:

local GamePassId = 19711172
If game.Players.PlayerAdded

??

I edited my code. It should work but why do you clone it in Bacpack and StarterPack? Wouldn’t it give the player two coils? I suggest only cloning in StarterPack.

Just following a tutorial which didn’t work, as the tool was not being given after purchasing through studio test

Oof. Have you tried my code yet? I’m sure it should work.

Just tried it, after test purchasing the ‘gravity coil’ button. The tool itself wasn’t given to me.

This is my Gravity Coil Buttons code:

	game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer,19711172)
end)```