Create a part behind an object instead of in front of it

Hello, I currently have a system to where it creates a giant beam. But when you create the next beam and the old beam is still there, it goes in front of the beam.

I know its something with Mouse.TargetFilter but that’s it.

Here’s the code:

m.KeyDown:connect(function(key)
key = key:lower()
if key == "2" and game.Players.LocalPlayer.Stats.CanAttack.Value == true then
	
	game.Players.LocalPlayer.Stats.CanAttack.Value = false
	game.Players.LocalPlayer.Stats.Phase.Value = "Attacking"
	
	local plr = game.Players.LocalPlayer
	local char = plr.Character
	local hum = char.Humanoid

	local anim = hum:LoadAnimation(script:FindFirstChild("FireAnim"))
	
	local Lightning = script.Effect.Thunder:Clone()
	Lightning.Parent = char["Left Arm"]
	Lightning.TrailElectricity.Script.Disabled = false
	
	local Lightning = script.Effect.Thunder:Clone()
	Lightning.Parent = char["Right Arm"]
	Lightning.TrailElectricity.Script.Disabled = false
	
	
	local Speed = hum.WalkSpeed
	local Jump = hum.JumpPower
	
	hum.WalkSpeed = 0
	hum.JumpPower = 0
	
	anim:Play()
	
	script.Sound:Play()
	
	wait(1)
	script.AttackEvent:FireServer(Mouse.Hit.p)

The script creates the actual part.

Thank you! Any help would be appreciated!

I really need help with this guys. : l

I think the simplest way to accomplish what you are asking is to create a folder, set the Mouse.TargetFilter to that folder and then parent the beams to the folder once they are created. Not sure if this works but I’m pretty sure there are more efficient methods than this.

I can’t figure out what you mean. Please post a screenshot or GIF of what’s wrong. It also doesn’t seem like that code does anything related to positioning the beams?

Here’s the game:

Push 2 with the kit Asriel and you’ll see what happens. It collides with the big beam.

I think what he’s asking is that when a player presses ‘2’, a ‘bullet’ gets created that lands on mouse.Hit. When the player fires again, mouse.Hit lands on the bullet instead of what’s behind the bullet. But yeah the script he posted has very little to do with the problem.

OMG! This actually worked! Thank you!