Help needed in scripting

My issue

I need to add a feature
the feature:
so if a player buys my gamepass he/she should get a pet while spawning as well as respawning and the pet should follow where ever the player goes

how do i script this thing?

1 Like

Alright first off do you have code, second do you have the gamepass setup

1 Like

So basically right when a player buys a gamepass you want them to spawn with a pet and then you also want them to respawn with the pet and you also want that pet to be able to follow the player?

1 Like

Hey there, so first I would suggest looking into MarketplaceService for the gamepass.

1 Like

You dont need a datastore for this, marketplace has a function that can tell you if the player owns the gamepass and if they do you can do whatever

https://developer.roblox.com/en-us/api-reference/function/MarketplaceService/UserOwnsGamePassAsync


1 Like

Apologies for this, I hardly use marketplace.

1 Like

No problem just read the api a bit more

1 Like

yes of Course
and i have already setup the model of the bet and gamepass

Do you have a draft of any scripts we could help you out with?

1 Like

Here I got this set up for you

So basically what Im doing is in a player added event im just checking if the player has the gamepass and if they do then blah blah

edit: this isnt the whole script, you still have to make the pet model or whatever follow the player, you can do that using bodygyro for orienting it and then bodyposition for smoothly moving it

local mps = game:GetService("MarketplaceService")

local petgamepass -- whatever

local petModelLocation -- whatever



game.Players.PlayerAdded:Connect(function(p)
	local petPass = mps:UserOwnsGamePassAsync(p.UserId,petgamepass)
	p.CharacterAdded:Connect(function(c)
		if petPass then
			-- owns pass
		end
	end)
end)

this can help you probably

2 Likes

can you please tell me what to add in petmodlelocaton?

You add where the pet is like serverstorage or replicated storage wherever you have it; also dont forget to do Clone:() at the end so that it clones for each player