iOSdeveloper

Untitled

Jun 18th, 2025
6
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. local replicatedStorage = game:GetService("ReplicatedStorage")
  2. local collectionService = game:GetService("CollectionService")
  3. local players = game:GetService("Players")
  4.  
  5. local localPlayer = players.LocalPlayer
  6.  
  7. local hatchFunction = getupvalue(getupvalue(getconnections(replicatedStorage.GameEvents.PetEggService.OnClientEvent)[1].Function, 1), 2)
  8. local eggModels = getupvalue(hatchFunction, 1)
  9. local eggPets = getupvalue(hatchFunction, 2)
  10.  
  11. local espCache = {}
  12. local activeEggs = {}
  13.  
  14. local function getObjectFromId(objectId)
  15. for eggModel in eggModels do
  16. if eggModel:GetAttribute("OBJECT_UUID") ~= objectId then continue end
  17. return eggModel
  18. end
  19. end
  20.  
  21. local function CreateEspGui(object, text)
  22. local billboard = Instance.new("BillboardGui")
  23. billboard.Name = "PetEggESP"
  24. billboard.Adornee = object:FindFirstChildWhichIsA("BasePart") or object.PrimaryPart or object
  25. billboard.Size = UDim2.new(0, 200, 0, 50)
  26. billboard.StudsOffset = Vector3.new(0, 2.5, 0)
  27. billboard.AlwaysOnTop = true
  28.  
  29. local label = Instance.new("TextLabel")
  30. label.Parent = billboard
  31. label.Size = UDim2.new(1, 0, 1, 0)
  32. label.BackgroundTransparency = 1
  33. label.Text = text
  34. label.TextColor3 = Color3.new(1, 1, 1)
  35. label.TextStrokeTransparency = 0
  36. label.TextScaled = true
  37. label.Font = Enum.Font.SourceSansBold
  38.  
  39. billboard.Parent = object
  40. return billboard
  41. end
  42.  
  43. local function UpdateEsp(objectId, petName)
  44. local object = getObjectFromId(objectId)
  45. if not object or not espCache[objectId] then return end
  46.  
  47. local eggName = object:GetAttribute("EggName")
  48. local labelGui = espCache[objectId]
  49. if labelGui and labelGui:FindFirstChildOfClass("TextLabel") then
  50. labelGui.TextLabel.Text = `{eggName} | {petName}`
  51. end
  52. end
  53.  
  54. local function AddEsp(object)
  55. if object:GetAttribute("OWNER") ~= localPlayer.Name then return end
  56.  
  57. local eggName = object:GetAttribute("EggName")
  58. local petName = eggPets[object:GetAttribute("OBJECT_UUID")]
  59. local objectId = object:GetAttribute("OBJECT_UUID")
  60. if not objectId then return end
  61.  
  62. local esp = CreateEspGui(object, `{eggName} | {petName or "?"}`)
  63. espCache[objectId] = esp
  64. activeEggs[objectId] = object
  65. end
  66.  
  67. local function RemoveEsp(object)
  68. if object:GetAttribute("OWNER") ~= localPlayer.Name then return end
  69.  
  70. local objectId = object:GetAttribute("OBJECT_UUID")
  71. if espCache[objectId] then
  72. espCache[objectId]:Destroy()
  73. espCache[objectId] = nil
  74. end
  75. activeEggs[objectId] = nil
  76. end
  77.  
  78. for _, object in collectionService:GetTagged("PetEggServer") do
  79. task.spawn(AddEsp, object)
  80. end
  81.  
  82. collectionService:GetInstanceAddedSignal("PetEggServer"):Connect(AddEsp)
  83. collectionService:GetInstanceRemovedSignal("PetEggServer"):Connect(RemoveEsp)
  84.  
  85. local old
  86. old = hookfunction(getconnections(replicatedStorage.GameEvents.EggReadyToHatch_RE.OnClientEvent)[1].Function, newcclosure(function(objectId, petName)
  87. UpdateEsp(objectId, petName)
  88. return old(objectId, petName)
  89. end))
Add Comment
Please, Sign In to add comment