Spawn model on top of part

Some of my models would spawn on top of the part but other models would spawn a little higher.

local modelSize = model:GetBoundingBox()
model:PivotTo(spawn.CFrame + Vector3.new(0,(spawn.Size.Y+modelSize.Y),0))

I think its because the tools are making the character higher?

1 Like

It could be the hats, and probably the tools (as you’re moving the model which includes every thing inside of it.). I suggest to use a dummy and remodel it but leave the HumanoidRootPart. And position the Humanoid Root Part not the whole model)

I don’t know what you mean. My HumanoidRootPart has always been the same.

I meant don’t move it by the model. Just position the humanoid root part and everything in the model will follow it, it won’t change because theres no differential height in humanoid root parts.

Just tried it but same problem.

model.PrimaryPart.CFrame = spawn.CFrame + Vector3.new(0,(modelSize.Y/2+spawn.Size.Y/2),0)

Do they all spawn at the same height. You’re sure you did not change the size of humanoidrootpart

Ohhh wait. I put the code in a different script. Let me change that.

Now change it a bit so its according to how you would like it. Trial and error basically.

It’s possible that the tool is adding some extra height to the character, causing the models to spawn a little higher than expected. One solution would be to adjust the Y offset in the PivotTo function to compensate for the extra height.

For example, if you know that the tool adds 1 stud of height to the character, you could adjust the Y offset like this:

local modelSize = model:GetBoundingBox()
local yOffset = spawn.Size.Y + modelSize.Y + 1 -- add 1 stud for the tool height
model:PivotTo(spawn.CFrame + Vector3.new(0, yOffset, 0))

This should ensure that the models always spawn at the correct height, regardless of any extra height added by the tool.

Do what i said in my other post, trial and error. position by humanoid root part and either increase the Y height or decrease. Y + 23 or what ever you like

I decided to resize the humanoidrootpart to the whole model size. How would I make that work?

If you want but I think that can ruin animation in general. I perfer to do trial and error so my humanoidrootpart size is normal

Got it to work! Animation still works when scaling the root.

local modelSize = model.PrimaryPart.Size
model.PrimaryPart.CFrame = spawn.CFrame + Vector3.new(0,(modelSize.Y/2+spawn.Size.Y/2),0)

DO you want to know why position from model is not good? (Noice work btw)

Yes. I always use PivotTo to position models.

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