Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

WHO CAN TEACH ME ABOUT GAMEPASS PET SCRIPT?

I MADE SOME SCRIPT BUT IT'S NOT WORKING AANYMORE. HERE'S SCRIPT

local pet = game.ReplicatedStorage.basic

script.Parent.Touched:connect(function(hit)
 if hit.Parent:FindFirstChild("Humanoid") ~= nil then
  local ply = game.Players:GetPlayerFromCharacter(hit.Parent)
  game:GetService("MarketplaceService"):PromptProductPurchase(ply, 9069958)

 end
end)

  if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId,9069958) then
function givePet (player)
 if player then
  local character = player.Character
  if character then
   local humRootPart = character.HumanoidRootPart
   local newPet = pet:Clone ()
   newPet.Parent = character

   local bodyPos = Instance.new("BodyPosition", newPet)
   bodyPos.MaxForce = Vector3.new(math.huge, math.huge, math.huge)

   local bodyGyro = Instance.new("BodyGyro", newPet)
   bodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)

   while wait() do
   bodyPos.Position = humRootPart.Position + Vector3.new(2, 2, 3)
    bodyGyro.CFrame = humRootPart.CFrame
   end
  end)

4 comments

0

You never called givePet?

0

did u try an else? after your if character and if player?

0

you didnt put all of your ends in

0

Make sure you dont delete your ends the are very important.

1 answer

You didn't put all of your ends in:

local pet = game.ReplicatedStorage.basic

script.Parent.Touched:connect(function(hit)
 if hit.Parent:FindFirstChild("Humanoid") ~= nil then
  local ply = game.Players:GetPlayerFromCharacter(hit.Parent)
  game:GetService("MarketplaceService"):PromptProductPurchase(ply, 9069958)

 end
end)

  if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId,9069958) then
function givePet (player)
 if player then
  local character = player.Character
  if character then
   local humRootPart = character.HumanoidRootPart
   local newPet = pet:Clone ()
   newPet.Parent = character

   local bodyPos = Instance.new("BodyPosition", newPet)
   bodyPos.MaxForce = Vector3.new(math.huge, math.huge, math.huge)

   local bodyGyro = Instance.new("BodyGyro", newPet)
   bodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)

   while wait() do
   bodyPos.Position = humRootPart.Position + Vector3.new(2, 2, 3)
    bodyGyro.CFrame = humRootPart.CFrame
   end
  end
end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.