How do i make a holdable lazer gun?

Hey i want to make a gun thats sort of like this
**


**

where theres some sort of lazer coming out of the firePart into the target

I dont need a script i just need some tips on how should i go about it.

What im going for is that as the player is holding the mouse 1 it dispenses some kind of ray/laser and a GUI bar is being drained and once it is drained it needs to charge back up.

ive thought of making some sort of an smg script where as i hold it i subtract 1 from the max number of bullets and connect that to the gui. But would that be the most efficient way? Edit: Im also gonna use raycast in this and an unrealiable remote event for shorter delay.

and how would i go about the ray/lazer should i just make an extremely long part and cut it to the distance of the part and target? that’s the part im having the most difficulty how since not only do i have to come up with how do i make it but also how do i replicate it (since im not too experienced with replicating)

You can probably use a beam for that honestly

Just shoot a raycast from the tip of your pistol and wherever it lands attach an Attachment to that Positions, Attachment0 will be your Pistol’s tip and Attachment1 will be the hit position (raycast hit)

To drain bullets you would do something similar I guess

When player holds down the left mouse button you would do PlayerShooting = true
When player lets go of the button you would do PlayerShooting = false

while PlayerShooting do
  Bullet.Value -= 1     
  task.wait(WAITTIME)
end

Not sure sorry :[

Right but what if i wanted the ray to have like a zigzaggy shape like a lightning shape how would i achieve that? can i achieve that with a beam?