Part not being spawned in where it's supposed to

  1. What do you want to achieve? Keep it simple and clear!
  • I’m trying to make a casing eject system for my gun system
  1. What is the issue? Include screenshots / videos if possible!
  • For some reason, most of the time the part isn’t spawning at the given position, but rather spawning like 50 studs below where it’s supposed to.
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
  • I tried using alternatives like PivotTo, and I looked everywhere on the forum to see if anyone’s having the same issue but it looks like it’s just me.

Here’s my code:

function casingEject()
	local casingEject : BasePart = framework.module.casing:Clone()
	casingEject.Parent = workspace
	casingEject.CFrame = framework.viewmodel.boltPos.CFrame
	
	--game.Debris:AddItem(casingEject,6)
	local casingVelocity = Vector3.new(50,20,0)
	casingEject.AssemblyLinearVelocity = framework.viewmodel.boltPos.CFrame:VectorToWorldSpace(casingVelocity)
end

and here’s a video of the problem:

Can you show what boltPos is?

It’s a part in the viewmodel which is supposed to be where the casing spawns in. (also i already checked and its welded correctly)

Try outputting the CFrames, check if they are indeed correct.

I printed both the casing’s CFrame and the boltPos’ CFrame and it outputs the same thing.

Try just spawning them in without applying any velocity, if they’re still not spawning at where you expect them, maybe the casing’s pivot is offset.

I removed the code for the velocity and tried again but it still doesn’t work. I made sure to reset the casing’s pivot in studio, is there a way to reset it within the code or something? Don’t know if it will work though

random solution but I guess you could try to move it up again by 50 studs?

Oh i fixed it already i just forgot to mark this as solved

The viewmodel was unanchored and i was changing its position every frame, which caused the positions to be “falling”

1 Like

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