Inserting parts through a script snaps ontop of Character

I made this very simple line of code a few weeks or so ago, and just recently it started behaving differently compared to how it used to.
What it’s supposed to do is spawn a part which is cloned from a folder and placed on the humanoid’s RootPart position minus 3 in height.
The parts I’m having it choose out of both have no collision, they’re also anchored.

Reason I added “wait(0.05)” is because sometimes it tended to spawn the part too fast and it ended up being incorrectly placed.

Code of reference

What it used to be until approx. an hour ago

09474b9b53332adf417ea55b13ffd80d

What it is now

97f416922edf1ad298c14ca584c91f54

It seems to work fine unless I subtract equal to or greater than -3.
The cloned part still spawns in any other parts besides the player itself.
Is there any explanation as to why this suddenly started happening?

I’m not perfectly sure why this started happening… it should have always been like that. When you set the position of a part, it will automatically be placed above any parts it collides with.

To fix this, set the CFrame of the part instead of the Position:

smoke.CFrame = CFrame.new(GetPposition(partPosition))

PS: Your “partPosition” variable is worthless. You have a local variable inside of your SpawnSmoke function that defaults to nil and a global variable (doing nothing) that gets set whenever GetPposition runs. It might be better to just return the Vector3 value in the GetPposition function.

4 Likes

Thank you! And thank you again for the tip!