:MoveTo and :SetPrimaryPartCFrame is giving me a hard time

I’m working for a group called Mano County. We’re supposed to be releasing our game soon but the spawning system for a certain department keeps giving me a hard time. Basically, when a player clicks a button on a GUI, it spawns in the desired vehicle. In this instance, it’s a fire truck. For some odd reason, this truck keeps spawning on top of the roof. I’ve tried to move the spawn, and it still isn’t working. Is there any fix for this?

1 Like

Don’t use move to, the problem with this function is it will try to spawn it on the top of anything above the position, so it’s not a good function when spawning near a building

2 Likes

well this might be dumb but,

local model = modelpathhere

model.PrimaryPart.CFrame = CFrameHere, --or if you want position replace .CFrame with .Position and put a vector at the CFrameHere

The fire truck shouldn’t be spawning on the roof unless you messed up somewhere in your script. Try moving the model’s PrimaryPart and see if that makes a difference.

1 Like

Can you show us the script you are referring to* so that we can help you better. I don’t wanna spam replies about questions of how you made it. When you can just show… but if you want to, of course, no pressure :smile:

How big is the SelectionBox of the model when you select it? If it’s based off some diagonal Part (if you didn’t select the PrimaryPart of the model manually) or if the space you are trying to insert it into has some MeshParts or other items that are interfering with the fit of the fire truck then your game may be telling you “that model won’t fit in this small space” and putting it above the designated area.

Well you should probably make sure that the position of the PrimaryPart in the model is correct. Then check the CFrame you where you are actually putting it.

Other than that I can’t think of a reason why ot shouldn’t work.

Are there any errors?

next time check the dev reference page first

“MoveTo will not move a model inside of an obstruction the Model is moved up on the Y axis and placed above the obstruction.”

quote source: Model:MoveTo