-
What do you want to achieve?
~ I want to understand why my Gamepass item doesn’t show up. -
What is the issue?
~ Gamepass item does not appear in inventory (or anywhere else that I can see). -
What solutions have you tried so far?
~ Much googling/forum-searching/experimenting, multiple tutorial videos, Roblox documentation.
So in my game I have a… (let’s just call it a horse) that can be ridden by the player, and provides some fun animations and extra speed and stuff. At the moment they’re just, on the map for people to hop on and off, but I want them to be gamepass purchases so only that player can access/use their horse.
I have various thoughts on why this isn’t working, but I’m so painfully new to scripting I have no idea where to go from here.
I have a building in my game that players can walk into and look around and buy stuff. The horses are outside, and by each there’s a post (literally just a wooden part). When you click on the part, you get the prompt to buy the pass.
Here is the Script for that…
localMarketplaceService = game:GetService("MarketplaceService")
local players = game:GetService("Players")
local id = 804048941
local function onTouch(hit)
local player = players:GetPlayerFromCharacter(hit.Parent)
if player then
localMarketplaceService:PromptGamePassPurchase(player, id)
end
end
script.Parent.Touched:Connect(onTouch)
The horse is sitting waiting in ReplicatedStorage for someone to buy it.
In ServerScriptService there is this Script…
local MarketplaceService = game:GetService("MarketplaceService")
local id = 804048941
local ToolName = {"LottiHorse"}
game.Players.PlayerAdded:Connect(function(Player)
if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, id) then
Player.CharacterAdded:Connect(function(character)
for Num, Tool in pairs(ToolName) do
if game:GetService("ReplicatedStorage"):FindFirstChild(Tool) then
game:GetService("ReplicatedStorage")[Tool]:Clone().Parent = Player.Backpack
end
end
end)
for Num, Tool in pairs(ToolName) do
if Player.Backpack:FindFirstChild(Tool) == nil then
if game:GetService("ReplicatedStorage"):FindFirstChild(Tool) then
game:GetService("ReplicatedStorage")[Tool]:Clone().Parent = Player.Backpack
end
end
end
end
end)
So that’s what’s supposed to happen.
Theories/points to note:
The horse is a MODEL, not a tool. I don’t know if that makes a difference because I’m script-dumb, but I tried replacing every mention of “tool” with “model” and it still just, doesn’t work.
Currently the player mounts the horse using a ProximityPrompt. Not sure if that might fighting with getting stuffed in the inventory?
Not sure if relevant but the horse is controlled by way of the ProximityPrompt connecting a MotorD6 from the player HumanoidRootPart to the HRP in the horse.
So I go up to the post in the game, I click it, it tells me I already own the gamepass.
Good.
So where is my horse? Cause the inventory ain’t it.
I got the gamepass ID from the asset ID of the pass.
I read somewhere that was wrong so I got it from the pass URL instead.
Turns out it’s the same number.
Thank you for reading.