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

i want to make gamepass pet but my script is not working why?

local PassService = game:GetService("GamePassService")
    local pet = script.Parent
 
game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(char)
        local check = PassService:PlayerHasPass(player,9069958)
        if check == true 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

1 answer

✓ Accepted answer
  1. You added a space before a couple parameters. I've never tried doing that, so I'm not sure if that affects the script (but I think it probably would).

  2. You never called your givePet(player) function, and you didn't end) all three of your functions.

  3. This is the first time I've seen anyone use GamePassService. Check to see if the ID you're using is the Asset ID of a legacy gamepass. For more info: https://developer.roblox.com/en-us/api-reference/class/GamePassService

Hope this helps!

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