How to make shoot trail?

Hello there,
I recently made simple gun that is using raycasting to detect what part was hitted
but I want make the shoot trail like in Murder Mystery 2 when sherif shoots
Thanks for any help!

1 Like
  1. Create a CFRame, so you know which way the bullet needs to rotate;
local CF = CFrame.new(GunBarrel.Position,RayHit) -- both are Vector3
  1. Creat a the bullet part.
local Bullet = Instance.new("Part")
Bullet.Anchored = true
Bullet.Cancollide = false
Bullet.Transparency = .5
Bullet.Parent = workspace
  1. Get the lenght of the bullet and create a width
local Width = .5
local Lenght = (GunBarrel.Position - RayHit).Magnitude

Bullet.Size = Vector3.new(Width,Width,Lenght)
Bullet.CFrame = CF --+ Bullet.Size/2
  1. Destroy the bullet
game:GetService("Debris"):AddItem(Bullet,.5)
2 Likes

It is not working it creates randomly facing part

My script is this:

	local BulletCF = CFrame.new(plr.Character[toolname].Handle.Position,part.Position)
		local Bullet = Instance.new("Part",workspace)
		Bullet.Name = "ShootBullet"
		Bullet.Anchored = true
		Bullet.CanCollide = false
		Bullet.Transparency = 0.5
		local Width = 0.5
		local Lenght = (plr.Character[toolname].Handle.Position - part.Position).Magnitude
		Bullet.Size = Vector3.new(Lenght,Width,Width)
		Bullet.CFrame = BulletCF + Bullet.Size

Btw, note it’s better to use.

local Bullet = Instance.new("Part")
Bullet.Parent = workspace

There’s an article about this.

What ? I think this do not helps me

Yes, but just a performance issue.
Other then that You’d need to fire this part of the script once you equiped it and clicked, as what you’re doing now is firing it whenever.

No, This happens only when client fire event to shoot and it will check if hit part exist

I changed something at point 3, but I am still not sure if it would work completely.
Oh and I noticed another thing I did wrong was use the whole Lenght of the bullet, but I’d only need to move it 1/2th of it’s size, so I fixed it.
And I added point 4.

Anyways, It is still do not working

I fixed the issue that it’s not facing the Part, but I am not sure how to fix the issue of it not being centered right.

So that means what ? I don’t know what you mean

I fixed the issue of the bullet not rotating right, but I didn’t fix the issue of the part not being centered in between the 2 parts.