Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local replicatedStorage = game:GetService("ReplicatedStorage")
- local collectionService = game:GetService("CollectionService")
- local players = game:GetService("Players")
- local localPlayer = players.LocalPlayer
- local hatchFunction = getupvalue(getupvalue(getconnections(replicatedStorage.GameEvents.PetEggService.OnClientEvent)[1].Function, 1), 2)
- local eggModels = getupvalue(hatchFunction, 1)
- local eggPets = getupvalue(hatchFunction, 2)
- local espCache = {}
- local activeEggs = {}
- local function getObjectFromId(objectId)
- for eggModel in eggModels do
- if eggModel:GetAttribute("OBJECT_UUID") ~= objectId then continue end
- return eggModel
- end
- end
- local function CreateEspGui(object, text)
- local billboard = Instance.new("BillboardGui")
- billboard.Name = "PetEggESP"
- billboard.Adornee = object:FindFirstChildWhichIsA("BasePart") or object.PrimaryPart or object
- billboard.Size = UDim2.new(0, 200, 0, 50)
- billboard.StudsOffset = Vector3.new(0, 2.5, 0)
- billboard.AlwaysOnTop = true
- local label = Instance.new("TextLabel")
- label.Name = "TextLabel"
- label.Parent = billboard
- label.Size = UDim2.new(1, 0, 1, 0)
- label.BackgroundTransparency = 1
- label.Text = text
- label.TextColor3 = Color3.new(1, 1, 1)
- label.TextStrokeTransparency = 0
- label.TextScaled = true
- label.Font = Enum.Font.SourceSansBold
- local gradient = Instance.new("UIGradient")
- gradient.Color = ColorSequence.new({
- ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 0, 0)),
- ColorSequenceKeypoint.new(0.17, Color3.fromRGB(255, 127, 0)),
- ColorSequenceKeypoint.new(0.33, Color3.fromRGB(255, 255, 0)),
- ColorSequenceKeypoint.new(0.5, Color3.fromRGB(0, 255, 0)),
- ColorSequenceKeypoint.new(0.67, Color3.fromRGB(0, 0, 255)),
- ColorSequenceKeypoint.new(0.83, Color3.fromRGB(75, 0, 130)),
- ColorSequenceKeypoint.new(1, Color3.fromRGB(148, 0, 211))
- })
- gradient.Rotation = 0
- gradient.Parent = label
- task.spawn(function()
- while true do
- local tween = game:GetService("TweenService"):Create(gradient, TweenInfo.new(5, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {Rotation = gradient.Rotation + 360})
- tween:Play()
- tween.Completed:Wait()
- gradient.Rotation = 0
- end
- end)
- local stroke = Instance.new("UIStroke")
- stroke.Thickness = 3
- stroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Contextual
- stroke.Parent = label
- billboard.Parent = object
- return billboard
- end
- local function UpdateEsp(objectId, petName)
- local object = getObjectFromId(objectId)
- if not object or not espCache[objectId] then return end
- local eggName = object:GetAttribute("EggName")
- local labelGui = espCache[objectId]
- if labelGui and labelGui:FindFirstChildOfClass("TextLabel") then
- labelGui.TextLabel.Text = `{eggName} | {petName}`
- end
- end
- local function AddEsp(object)
- if object:GetAttribute("OWNER") ~= localPlayer.Name then return end
- local eggName = object:GetAttribute("EggName")
- local petName = eggPets[object:GetAttribute("OBJECT_UUID")]
- local objectId = object:GetAttribute("OBJECT_UUID")
- if not objectId then return end
- local esp = CreateEspGui(object, `{eggName} | {petName or "?"}`)
- espCache[objectId] = esp
- activeEggs[objectId] = object
- end
- local function RemoveEsp(object)
- if object:GetAttribute("OWNER") ~= localPlayer.Name then return end
- local objectId = object:GetAttribute("OBJECT_UUID")
- if espCache[objectId] then
- espCache[objectId]:Destroy()
- espCache[objectId] = nil
- end
- activeEggs[objectId] = nil
- end
- for _, object in collectionService:GetTagged("PetEggServer") do
- task.spawn(AddEsp, object)
- end
- collectionService:GetInstanceAddedSignal("PetEggServer"):Connect(AddEsp)
- collectionService:GetInstanceRemovedSignal("PetEggServer"):Connect(RemoveEsp)
- local old
- old = hookfunction(getconnections(replicatedStorage.GameEvents.EggReadyToHatch_RE.OnClientEvent)[1].Function, newcclosure(function(objectId, petName)
- UpdateEsp(objectId, petName)
- return old(objectId, petName)
- end))
Advertisement
Add Comment
Please, Sign In to add comment