Pet hatch script not working

Hey devs, my friend helped me with a script but it’s still not working. My pets are were they should be but on line 28 of my script it says “CFrame is not a valid member of Fox” This is with all the other pets too. I don’t know how to fix it.

1 Like

Models don’t have CFrames, only parts, mesh parts etc. I advise you get the HumanoidRootPart’s CFrame of the Fox instead like

Fox.HumanoidRootPart.CFrame

Ok good to know. But where should I put the “Fox.HumanoidRootPart.CFrame” in? Like what line of code.

The pet also doesn’t have a humanoid root part how would I add it in?

Where it called the error, on that line.

Replace what I think it says right now somewhere on that line

Fox.CFrame 

with

Fox.PrimaryPart.CFrame

if it does not have a humanoid root part

This is only if it is rigged and has a humanoid. It should have a PrimaryPart

It doesn’t say Fox.CFrame on that line it says this:

Screen Shot 2021-04-28 at 5.43.11 PM

Alright you said this is for all pets so let me explain. Models don’t have CFrame like I had said earlier. So if the pet you are cloning (whatever is may be) is a model, then get their CFrame by looking for their PrimaryPart/HumanoidRootPart/Torso.

So

petClone.PrimaryPart.CFrame = egg.CFrame

If egg is a model then you need to get the CFrame of any part inside the model or its PrimaryPart (idk if its has a humanoid). If the egg is a part then it would be fine.

This helped but now on line in my other script it says this:

The red is the problem and the grey highlighted part is the line the problem occurred on

Yes lol like I said earlier change the petClone.CFrame . to petClone.PrimaryPart.CFrame
This is because it’s a model.

Just a side note but this is in the wrong category, should belong in #help-and-feedback:scripting-support

You first have to set the PrimaryPart of the Model, then define the Model’s PrimaryPart CFrame that way

is this showing a cool script text or something? #help-and-feedback:scripting-support

Models dont have CFrames. To get the Primary Parts CFrame, do :GetPrimaryPartCFrame(), but if you are setting it, use :SetPrimaryPartCFrame(). If your game will not release until a few months, consider using :PivotTo(), :GetPivot(), etc…

Thanks this worked!
Ill put is as solution! :smiley:

If you need to move the entire model, you can use Model:SetPrimaryPartCFrame as models doesn’t have a CFrame property.

More information can be found here: Model | Roblox Creator Documentation
This function ignores collisions and is faster than Model:MoveTo, which can be annoying since it might not end up where you want to due to collisions if you have invisible parts or parts in general close to it, etc etc.