so i’m trying to make an egg hatching system so that the egg pops up and hatches a pet so I tried using chat GPT and this is the closest I got:
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local backpack = player:WaitForChild("Backpack")
local hatching = false
local origamimaster7225 = workspace:FindFirstChild("origamimaster7225")
local egg = origamimaster7225 and origamimaster7225:FindFirstChild("Egg")
local clickDetector = egg and egg:FindFirstChild("ClickDetector")
if clickDetector then
clickDetector.MouseClick:Connect(function(playerWhoClicked)
if not hatching and playerWhoClicked == player then
hatching = true
local eggModel = character:FindFirstChild("EggModel")
local petModel = character:FindFirstChild("PetModel")
if eggModel and petModel then
eggModel:SetPrimaryPartCFrame(CFrame.new(0, 5, 0))
local hatchSound = eggModel:FindFirstChild("HatchSound")
if hatchSound then
hatchSound:Play()
end
petModel:SetPrimaryPartCFrame(CFrame.new(0, 0, 0))
local humanoid = petModel:FindFirstChildOfClass("Humanoid")
if humanoid then
local animator = humanoid:FindFirstChildOfClass("Animator")
if animator then
local petAnimation = petModel:FindFirstChild("IdleAnimation")
if petAnimation then
local animationTrack = humanoid:LoadAnimation(petAnimation)
animationTrack:Play()
end
end
end
end
local clonedEgg = egg:Clone()
clonedEgg.Parent = workspace
local billboardGui = Instance.new("BillboardGui")
billboardGui.AlwaysOnTop = true
billboardGui.Enabled = true
billboardGui.Size = UDim2.new(4, 0, 4, 0)
billboardGui.Adornee = clonedEgg.PrimaryPart
billboardGui.Parent = clonedEgg.PrimaryPart
local imageLabel = Instance.new("ImageLabel")
imageLabel.Size = UDim2.new(1, 0, 1, 0)
imageLabel.BackgroundTransparency = 1
imageLabel.Image = "rbxassetid://1527559" -- Replace with your egg image asset ID
imageLabel.Parent = billboardGui
local bodyPosition = Instance.new("BodyPosition")
bodyPosition.Position = character.HumanoidRootPart.Position
bodyPosition.Parent = clonedEgg.PrimaryPart
bodyPosition.Died:Connect(function()
clonedEgg:Destroy()
end)
end
end)
end
also let me know if you have a model instead with scripts