Problem with game pass not relocating asset from ReplicatedStorage into player

Nothing seems to work, this is the code used: (Just seeing if I copied all correctly)
If there’s any more information needed besides this local script do tell me because I’ll gladly share them!

local player = game.Players.LocalPlayer
local character = player.Character
local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,8530571)

game.Players.LocalPlayer.CharacterAdded:Connect(function(char)
	if ownsGamepass then
			repeat wait() until game:GetService("ReplicatedStorage"):FindFirstChild("Pet")
	                local pet = game:GetService("ReplicatedStorage"):FindFirstChild("Pet")
			pet.Parent = char
	end
end)

Try debugging, tell me if you what you see in the console if you put this code in:

local player = game.Players.LocalPlayer
local character = player.Character
local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,8530571)

game.Players.LocalPlayer.CharacterAdded:Connect(function(char)
	if ownsGamepass then
               print("THEY OWN THE PASS!")
        else
               print("WHERE IS THE PASS?!")
	end
end)

I am not sure why, but I am not getting any output, nor am I getting anything in the developer console.


Okay good! We found out it might not the be the inside code.
So now try doing this:

local player = game.Players.LocalPlayer
local character = player.Character
local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,8530571)

	if ownsGamepass then
               print("THEY OWN THE PASS!")
        else
               print("WHERE IS THE PASS?!")
	end

Without doing anything at all it now gives me this:

image

try the following

local player = game.Players.LocalPlayer
local character = player.Character

while true do
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,8530571) then
          local pet = game:GetService("ReplicatedStorage"):FindFirstChild("Pet")
		pet.Parent = character 
end
wait()
end

No that would inf loop it and if they never own the pass they will always have a loop running!

It must be a mistake on my end considering nothing happens at all. These are the only objects located inside the game. (There is only one LocalScript if I get rid of the old one, LocalScript2 that is.

image

Also, the gamepass does exist.
https://www.roblox.com/game-pass/8530571/1

I did correct your MarketPlaceService typo to MarketplaceService so that can’t be it either.

Try uploading it as a place and testing in actual roblox.

Doesn’t change a thing. (30 chars)

Would it help if I made the “game” editable to others so anyone could look around?

Okay so, since remember it said you didn’t own the gamepass, actually buy it.
Also here is the same script but gives you the pass when you don’t own the gamepass just for testing:

local MPS = game:GetService("MarketPlaceService")
local pet = game:GetService("ReplicatedStorage"):FindFirstChild("Pet")

local GamePassID = 8530571

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function( character )
		if MPS:UserOwnsGamePassAsync(player.UserId, GamePassID) then
			 pet:Clone().Parent = character
			 print("Pet given")
                else
                       	 pet:Clone().Parent = character
			 print("Pet given")
                        print("You didn't own the pass but I still gave you the pet!")
		end
	end)
end)

Try the edited version now.

1 Like

This actually worked, I did own the gamepass already. But I received the pet straight away after spawning in. I will also try this without owning the gamepass beforehand.

EDIT: So when I own the gamepass already and then join the game it gives me the pet, but it doesn’t give me the pet straight away without rejoining.

Just don’t forget to remove the part where it gives the player the pet when they don’t own the gamepass.
That part was for testing if it would say in the console you don’t own it.

I’m not sure if this works anymore try this:

local player = game.Players.LocalPlayer
local character = player.Character
local HasPass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,8530571)

local function check ()
if HasPass then
        local pet = game:GetService("ReplicatedStorage"):FindFirstChild("Pet")
		pet.Parent = character
end
end

player.CharacterAdded:connect:(check)
HasPass:GetPropertyChangedSignal():connect(check)

Thank you for contributing to the topic. Sorry for leaving you out, it wasn’t intentional. I will try that aswell!

I have joined the game owning, and not owing the gamepass. It only gives me the pet when I actually own the gamepass so that shouldn’t be an issue. Unfortunately the player does have to rejoin in order for them to receive their pet but I’m guessing that’s not too big of a problem as I can just mention it.

Are you trying to give pet after gamepass is bought in game?

Yes. (30 chars, 30 chars, 30 chars)

Gives me this error,
image