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.
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.
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
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.
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.
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
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
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)