Problem with game pass not relocating asset from ReplicatedStorage into player

Hello, my name is Dataspec or better known as Sy.
I am currently working on a ‘‘vibe’’ style game:

Progress so far, feel free to check it out and/or leave feedback

https://www.roblox.com/games/4764662259/vibe?refPageId=c6938b32-f3a1-4063-b202-c29e5a6c5088

But of course, with that also come game passes.
I currently have a fully functional “pet” that properly follows you around wherever you move:

However, in order for the “pet” to function it requires to be inside of the “player”
I have tried turning it into a game pass, I don’t have any issues creating one but I am unsure how to get the game pass (script) to move the pet into the “player” who has purchased the item, and how to permanently have it there so that every time the “player” rejoins or resets the “pet” will still be following them around. All I know is how to move the “pet” into Workspace upon purchase.

This uses a normal script although I think a local script would work too, the script (located in ServerScriptService):


local ItemId01 = 8530107 

MPS.PromptGamePassPurchaseFinished:Connect(function(player,assetId,isPurchased)
	if isPurchased then 
		if assetId == ItemId01 then 
					
	print('Player Has Bought GamePass')
		
-- this is line of code that tells the game where to move the pet to v
			local pet = game.ReplicatedStorage.Pet
					pet.Parent = game.Workspace
					
	else 
		print('Player Did Not Buy GamePass')
	end
		end
		end)

Sorry if my explanation is a bit unclear, I’m more of a modeller/builder. So not sure how to properly formulate this.

Thank you for your time!

1 Like

In order to move it to the player who bought the gamepass, first get their character local character = player.Character and then simply clone it in there.

you are putting the pet in the workspace, you have to put it in the player character.

I know this, but I do not know how. That is why I am asking on here for support.

I also have this local script which is located in ScreenGUI rather than the normal script.

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

if ownsGamepass then
 local pet = game:GetService("ReplicatedStorage"):WaitForChild("Pet"):Clone()
 pet.Parent = game.Workspace -- has to be located in the player instead
end

As I already said in the earlier post, since you have the player you can easily get it’s character by doing local character = player.Character and then cloning your pet in there

if ownsGamepass then
    local character = player.Character
    local pet = game:GetService("ReplicatedStorage"):WaitForChild("Pet"):Clone()
    pet.Parent = character
end
1 Like

I am now using this:

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

if ownsGamepass then
    local character = player.Character
    local pet = game:GetService("ReplicatedStorage"):WaitForChild("Pet"):Clone()
    pet.Parent = character
end

But unfortunately it still does not work, I’ll show you what I mean.

This is script placed inside of the TextButton

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

Does pet get cloned at all? Are there any errors?

Edit: You said you were using a server script earlier; Server scripts don’t run on client, you’ll have to use a local script, fire a remote event to server and clone the pet there in case you want the entire server to see it, not only you.

I don’t actually get any output at all.


image

You’re using a server script on client right? If so, make it a local script

The script I’ve just shown you is actually a local script. I had two scripts to work with, sorry for being unclear.

image

Oh no problem, so are you trying to get pet in the character once player joins the game in this script or what?

Yeah, basically upon purchase the pet should be moved inside of the player and stay there for eternity.

You might wanna have a server script and implement player added and character added event then

I used a ServerScript in the initial post, could you maybe take a look at that one?

Instead of

local pet = game:GetService("ReplicatedStorage"):WaitForChild("Pet"):Clone()

You could try

repeat wait() until game:GetService("ReplicatedStorage"):FindFirstChild("Pet")
local pet = game:GetService("ReplicatedStorage"):FindFirstChild("Pet")
-- other code here

Yeah I see; however you have to do the same thing now except you implement .PlayerAdded and .CharacterAdded event

local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,8530571)
local character = player.Character
	local pet = game:GetService("ReplicatedStorage"):FindFirstChild("Pet")

if ownsGamepass then
 
	    
	repeat wait() until game:GetService("ReplicatedStorage"):FindFirstChild("Pet")
    pet.Parent = character
end

I am not sure whether this is what you meant or not, but if it is. It unfortunately still doesn’t fix the problem.

If only I would figure out how. lol
It’s just tough when you can’t script at all. My knowledge is very limited.
Only stuff I have knowledge of is building, modelling, art and some basic animating/UI

Try this:

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)

Sorry I just edited it…