Chat gpt script fix please help

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

2 Likes

So what’s the problem? Also I realized you haven’t replaced this id with your own:

yeah ik so i clicked the part and an egg was suppose to pop up on my screen and hatch

Try putting a print statement above. Test it and see if it prints, if it does, then tell me.

ok does it matter what i print?

No, not really, it just a test to see if the script even goes that far or not.

Also, please keep in mind that the variables that define stuff have to actually be in your game. For example:

This egg needs to be you or the egg needs to be parented to your character. If it’s not, this won’t happen at all.

nothing worked and ok can you please give an example of how to do that?

Also, if you’re having trouble. I think for your case you should search up a YouTube tutorial instead of ChatGPT. Because ChatGPT only writes the code for you. And doesn’t actually do everything.

I’m not going to link a specific person, however just search up “Egg Hatching System Roblox Studio”.

kk do you have one that you can show me?

Yeah sure. The reason I’m recommending this is because it seems like you’re having a bit of trouble with this and it might take a while for me to manually tell you what to do each time.

Here’s the video:

However I’m unsure if this works because I haven’t used it before (nor do I plan to) I’ve read the comments and stuff but I’m pretty sure if you follow the directions in the video you should be good to go :+1:

thank you i appreciate your help

2 Likes

thank you thank you thank you works

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.