How to create a moving bullet in a straight line?


I made this bullet as an idea of what it would look like but I’m not sure how to script to go in the raycast’s direction and I don’t know which “velocity” to use. (Assembly linear velocity or linear velocity)

you can use fastcast to handle bullets and hit detection

usually you make fake bullets on each client and the bullet hitbox on the server

if you want to make your own system then you should probably anchor the bullet and then simulate the velocity in a script with

bullet.CFrame = bullet.CFrame + bullet.CFrame.LookVector * speed

where the bullet cframe is initially set to

CFrame.lookAt(firingPosition, targetPosition)

--or

CFrame.lookAt(firingPosition, firingPosition + raycastDirection)
2 Likes

Why is there always a guy in each post like you who will suggest bloatware for the game for no reason?
Why regular raycast is not enough for you?
Anyway, FastCast is made on loose types, so it must not be used in 2025.

1 Like

I think that using cframes or tweens to accomplish it is perfectly fine. I’m not sure if FastCast is needed here. I get that everyone uses it but, there’s a lot of functionality in it that your game probably doesn’t need or want. The whole “projectile lag” issue with it is a bit of experience-killer imo.

If you really want to make sure that the system is solid, track the start position (barrel) and the end position (your choice) and then, simulate the movement on the server. It’s very similar to “fast-forward”. You’re almost predicting where the bullet will land before it does.

After that, handle all cosmetics on the client. If the bullet’s end goal isn’t the same as the server’s then, the user probably exploited. If you want to get super creative, you can interpret the bullet’s trajectory as a line and check to see if the bullet’s position in 3D space matches a point (x, y, z) on the line. If it doesn’t, the user probably exploited.

I’ve been doing this for 10 years now. It’s simple. Don’t overthink it haha.

Neither;
Just use Beams
That’s kind of stupid when it has inconsistency when a flying bullet is physical but an actual hit is just a ray.

I don’t understand? I been told that fast cast is good

how is it good?
What does specifically it give to you?
Over abstraction on already abstracted raycast?
More over code is from 2021 era and it is lose typed without typechecking and uses outdated signal module.

To be honest, I only know it because people said it’s good. I never actually went deep into it

Just use raycasting
Boomer bloxers is still stuck in 2019 era :skull: and telling people to use FastCast
if you want to overoptimize the game you can:

local Raycast = workspace.Raycast

Although you will always have to pass workspace as the first argument, and it’s a little annoying but may boost performance by a little BIT, you are literally doing workspace:Raycast(), so you just swap position where you put workspace.
FastCast is essentially bloatware raycast that still lives in the 2019-2020 era; now only raycast/shapecast/blockcast/sphere casts are relevant.

Oh alright, also what should I use to make the bullet go into the raycast’s direction until I destroy it using Instance:Destroy or Debris? :thinking: (I’m just trying to make it look good)

You can instead use beams.
Spawn a beam part with an attachment on the end and attach other end of beam to a fire barrel, and then destroy goal part after, like, 1 second.
You will not have to worry about moving parts or performance loss with this technique+you can add a sort of animation gradient if you know beams.


Why is it not letting me set the attachments??

yeah its good idea keeping beam instead of destroying it ig.
You need to use Attachment instance parented to a part

Whoops wrong game, I meant from Underground War 2.0, where the bullet looks realistic and travels

Im pretty sure people had already made tutorials like “beam bullets” and such
if not on devforum then on YT for sure
like this: https://www.youtube.com/watch?v=UK3EDgbHgnU&ab_channel=20amir02

The beam looks nice but how do I cover the part?

do you mean hide the part? (filler text, lol)

you can make part compiletelly invisible.
All that metters is placement of a attachment.

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