Sungmingamerpro13

spawnPet with PlayerNameTag (EquipPetScript)

Jun 14th, 2026
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 0.73 KB | None | 0 0
  1. local function spawnPet(player, petName)
  2.  
  3.     -- 🧹 eliminar seguro anterior
  4.     if ActivePets[player] then
  5.         ActivePets[player]:Destroy()
  6.         ActivePets[player] = nil
  7.     end
  8.  
  9.     local character = player.Character
  10.     if not character then return end
  11.  
  12.     local hrp = character:FindFirstChild("HumanoidRootPart")
  13.     if not hrp then return end
  14.  
  15.     local petModel = game.ReplicatedStorage.petsFolder:FindFirstChild(petName)
  16.     if not petModel then return end
  17.  
  18.     local pet = petModel:Clone()
  19.     pet.Name = player.Name .. "_Pet"
  20.     pet.Parent = workspace
  21.    
  22.     local playerName = player.Name
  23.    
  24.     pet:FindFirstChild("PrimaryPart").nameTagGui.nameLabel.Text = playerName.."'s PET"
  25.  
  26.     pet:PivotTo(hrp.CFrame * CFrame.new(2, 0, 2))
  27.  
  28.     ActivePets[player] = pet
  29. end
Advertisement
Add Comment
Please, Sign In to add comment