Once Game Pass is purchased I'm not seeing it in my backpack

I have created 3 items that can be purchased with a Game Pass. Purchasing the item is working just fine, I’ve tested it, but the issue is that the items never appear into my Backpack to use. The systems takes me through the prompts to buy the items and says it was successful, it just does not ever show in the backpack.

The 3 items are Sword, monkey and flyingRock as show in the ReplicatedStorage of my Explorer.

screenshot of Server Storage screenshot of Gui screen shot items

This is the code in my MainGui

local MarketplaceService = game:GetService(“MarketplaceService”)
local MainFrame = script.Parent.MainFrame
local petGamepass1 = MainFrame.PetGamePassFrame1.PetGamepass1
local petGamepass2 = MainFrame.PetGamePassFrame2.PetGamepass2
local swordGamepass = MainFrame.SwordGamePassFrame.SwordGamepass
local Shop = MainFrame.Parent.Shop

local player = game.Players.LocalPlayer

local petGamepass1ID = 14004733
local petGamepass2ID = 14004754
local swordGamepassID = 13940834

petGamepass1.MouseButton1Down:Connect(function()
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, petGamepass1ID)
end)

if hasPass then
	print("player already has the gamepass")
else
	MarketplaceService:PromptGamePassPurchase(player, petGamepass1ID)
	
end

end)

petGamepass2.MouseButton1Down:Connect(function()
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, petGamepass2ID)
end)

if hasPass then
	print("player already has the gamepass")
else
	MarketplaceService:PromptGamePassPurchase(player, petGamepass2ID)

end

end)

swordGamepass.MouseButton1Down:Connect(function()
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, swordGamepassID)
end)

if hasPass then
	print("player already has the gamepass")
else
	MarketplaceService:PromptGamePassPurchase(player, swordGamepassID)

end

end)

Shop.MouseButton1Down:Connect(function()
MainFrame.Visible = not MainFrame.Visible
end)

& this is the code in Server Storage


local MarketplaceService = game:GetService(“MarketplaceService”)
local Players = game:GetService(“Players”)

local petGamepass1ID = 14004733
local petGamepass2ID = 14004754
local swordGamepassID = 13940834

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

local success, message = pcall(function()
	hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, petGamepass1ID)
end)

if hasPass then
	print("player has the gamepass")
	
	local flyingRock = game.ReplicatedStorage.flyingRock:Clone()
	flyingRock.Parent = player.Backpack
	
end

end)

local function onPromptGamePassPurchaseFinished(player, purchasedPassID, purchaseSuccess)

if purchaseSuccess == true and purchasedPassID == petGamepass1ID then
	print(player.Name.."purchased the game pass!")
	
	local flyingRock = game.ReplicatedStorage.flyingRock:Clone()
	flyingRock.Parent = player.Backpack
end

end

MarketplaceService.PromptGamePassPurchaseFinished:Connect(onPromptGamePassPurchaseFinished)

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

local success, message = pcall(function()
	hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, petGamepass2ID)
end)

if hasPass then
	print("player has the gamepass")

	local monkey = game.ReplicatedStorage.monkey:Clone()
	monkey.Parent = player.Backpack

end

end)

local function onPromptGamePassPurchaseFinished(player, purchasedPassID, purchaseSuccess)

if purchaseSuccess == true and purchasedPassID == petGamepass2ID then
	print(player.Name.."purchased the game pass!")

	local monkey = game.ReplicatedStorage.monkey:Clone()
	monkey.Parent = player.Backpack
end

end

MarketplaceService.PromptGamePassPurchaseFinished:Connect(onPromptGamePassPurchaseFinished)

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

local success, message = pcall(function()
	hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, swordGamepassID)
end)

if hasPass then
	print("player has the gamepass")

	local Sword = game.ReplicatedStorage.Sword:Clone()
	Sword.Parent = player.Backpack

end

end)

local function onPromptGamePassPurchaseFinished(player, purchasedPassID, purchaseSuccess)

if purchaseSuccess == true and purchasedPassID == swordGamepassID then
	print(player.Name.."purchased the game pass!")

	local Sword = game.ReplicatedStorage.Sword:Clone()
	Sword.Parent = player.Backpack
end

end

MarketplaceService.PromptGamePassPurchaseFinished:Connect(onPromptGamePassPurchaseFinished)

1 Like

Scripts do not run in ServerStorage, so “ScriptGamePass” must be put into ServerScriptService. The monkey and the flying rock must be Tools, like the sword.

1 Like

Hmmmm, well changing it to tools equips them in my hand. This would be correct for the Sword, but not the two Pets which follow behind me. So this isn’t working as needed still.

Here is how it is setup now based on your suggestions, se my explorer screenshots below.

The script for the Sword however is no longer working. It goes into my hand but now It appears the Sword is not functioning.

If I have a Handle in both the monkey and the flyingRock they do equip into my hand but this is not what I want to happen. they should fly behind me like a Pet.

If I take the Handle out, they no longer appear in the game at all after I purchase them but i see the name of them appear at the bottom of my screen as if they are in the backpack.

The difference this time is they seem to appear into the backpack but with issues still. The flyingRock shows in the backpack but quickly disappears after a few seconds as if it were never there at all, if I quickly click on it before it disappears nothing happens the Pet never appears. The monkey appears in the backpack but if I click on it the Pet never appears.

screenshot of sword setup

screenshot of rock setup

My Pet Script which is in the tool.

local newPet = script.Parent

newPet.CanCollide = false

newPet.Anchored = false

local petPos = Instance.new(“BodyPosition”, newPet)

local petGyro = Instance.new(“BodyGyro”, newPet)

petGyro.MaxTorque = Vector3.new(900000,900000,900000)

local owner = newPet.ID.Value

local followPosition = Vector3.new(.5,.5,0)

while wait(1)do

local ownerObj = workspace:WaitForChild(owner)

local player = game.Players:FindFirstChild(ownerObj.Name)

local ownerPos = ownerObj.HumanoidRootPart.Position

local stopAt = ((ownerPos - newPet.Position).magnitude-1)*1000

petPos.P = stopAt

petPos.Position = ownerPos + followPosition

petGyro.CFrame = ownerObj.HumanoidRootPart.CFrame

end

My Sword Script which is in the tool

local tool = script.Parent

local function onTouch(partOther)

local humanOther = partOther.Parent:FindFirstChild("Humanoid")

if not humanOther then return end

if humanOther.Parent == tool then return end

humanOther:TakeDamage(100)

end

local function slash()

local str = Instance.new("StringValue")
str.Name = "toolanim"
str.Value = "Slash"
str.Parent = tool

end

tool.Activated:Connect(slash)
tool.Handle.Touched:Connect(onTouch)

Then you will need to revert the flying rock and monkey so that they are not tools anymore. Change the game pass script so that the pets are parented to workspace instead of the player’s backpack. For the sword, try the scripts from ROBLOX’s sword in the Toolbox.

Workspace won’t work because I don’t want the Pets to always be present. I need the button at the bottom of the screen so if the player has bought the Game Pass they now own the pet and can use it in the game.

When I have the Pets as a tool they show at the bottom but have issues still.

Here are the Items showing at the bottom of the screen, after I make the purchase

Here is what the Explorer window looks like, the items are in the players Backpack
Screenshot of explorer showing the tools in the Backpack

This is my Output window showing errors in the script for all three items, so it appears the script in each item has an issue with how it is setup
Screenshot of my output showing errors

robloxapp-20210115-0811573.wmv (3.3 MB)

If I click either one of the pets to equip, they both just disappear completely from the screen and are gone. This is what happens in my explorer window after I click each tool as shown in the video above.
Screenshot of explorer after ive clicked to equip the items, the pets are missing

Rock Script , line 11 shows error in Output window
Screenshot of rock script

Monkey Script, line 8 shows error in Output window
Screenshot of monkey script

The Sword script, I tried one from the Roblox sword and its getting an error too
Screenshot snippet of Sword script

For the last few days, I’ve been changing the script around on those lines trying to find what is wrong to get it working but its obviously beyond me at this point still. :woozy_face:

I really appreciate the help !

I’ve still not been able to get this working. I tried another tutorial and started over on the process and again I get to the point that I can purchase the item, in this case the pet, but it never goes into a backpack for me to use.

Whats player set as because i think its erroring because player doesn’t exist

What do you mean, what is player set at ? Please explain more clearly what you are asking from me.

My player is in the game in Test/Play or Test/Server mode when I get the error message that I copied and pasted to show what is occurring.

I feel the responses I get for “help” here are very vague and not too helpful.

I mean what the player variable is set as

What is the player variable suppose to be and where should it be placed ?

image
Im talking about the player variable click on the errors and copy the player variable and post it since theres clearly an issue with it.

I already posted all of the scripts I am using above in the original post, the variables being used are already clearly defined in all the scripts. Are you asking me to post them again ?

Oh okay ill look at the pictures then.

Okay so can you go into the monkey and show me the newPet.player.ID and its value

Here is the monkey setup.

Value ID properties

Okay and what is the owners value ingame?

I’m not certain what you are asking ? Once the player purchases the gamepass, they have the gamepass ID number ? I already tried to put that number into the Value field but it didn’t work either.

I tried the players name as well, but it will be different for each player UserId ?

I got the Sword working, but neither of the two pets… which I detailed above also. I feel it is because of how the pets are setup. I really don’t feel it is script but I may not be correct for I am very new to this.

local petGamepass1ID = 14004733
local petGamepass2ID = 14004754
local swordGamepassID = 13940834

Im asking what is the value of ID ingame is it the value of the product id?

I do not know. The only two values I can think of to use would be the UserID or the Gamepass ID.

Wait so you didn’t script it also why is there a red line under bodyposition.