How would I have parts spawn inside a part only on the Y axis

Hello, I am trying to have a part only spawn inside a part on the Y axis,

And yes I have already tried to use NextNumber and randoms; what I tried to use:

fx.CFrame * CFrame.new(0,Random.new():NextNumber(-c.Size.Y/2,c.Size.Y/2),0)

Help is appreciated.

1 Like

Are you asking about having the part spawn on the Part’s Y-axis or the Global World’s Y-axis?

Also, can you give the application of what this is for because it’s really hard for me to understand why you need a part to spawn inside another part, but only on it’s Y-axis.

Basically just only spawning in an up-down manner with parts, its for a kill effect

Just add a Vector3 value to the part’s CFrame.

fx.CFrame += Vector3.new(0, yourNumber, 0) 

Another question, How do I have the part also appear at the top of the part and spawn a new part under said part?

A part positioned above another part has to be calculated by the following formuala:
Position of the bottom Part + 1/2 the height of the bottom Part plus 1/2 the height of the Part you are placing on top = the Position of the Part on top.

Same with placing a Part underneath the top Part.
Top Part Position - 1/2 height of top Part - 1/2 height of Part being put underneath = Position of Part underneath.

Very hard to understand what your asking here, but it seems like you could use ray tracing to find the position of the top of the part.

Give it a whitelist of the part, and start it at the position of the part plus a Y only Vector3. Then give it a direction of Vector3(0, -1, 0).

That would only work for a rectangular part, don’t use this method.

Works for Ball Parts too.
I assumed that because he only wants the new Parts placed on the Y axis that the Part was a Block and Oriented vertically, not at an angle.

Kind of like this

Without knowing the application, it’s impossible to know. But since it’s a kill effect I assume players would be involved.

Can you please explain the correlation between this and your original question.

It is what I am trying to replicate, The parts spawning on the player is my goal, with how they flow down the characters limbs.

These parts being spawned only spawn on the Y axis, not X or Z,

And my question about parts after parts is the flowing effect.

That has nothing to do with spawning inside a part only on the Y-axis. This is spawning around a part. That’s a much more complex effect and should have been shown in your original post.

I couldnt find a video of it until now.

The parts are moving up in the Y-axis, but they spawn in all 3.

Ive been searching this whole time

The parts are slightly rotated, I don’t think they’re spawning on X or Z, but lets say they are.