Roblox Trail problem

I use Roblox’s Trail to create a trail behind a bullet to create an effect. I use TweenService to move my gun bullets, when the bullet part was being created, i’ll create a trail and attach it to it’s back.

However, while the bullet is tweening in a high speed, it delays. I used this formula:
RaycastedDistance * time / stud
(Referenced from here: How do I tween a bullet effectively? - #5 by goldenstein64)

When I set the tweening time to 10 studs per 0.5 seconds, the trail shows normally from the bullet starting point, however, when I shorten it to 0.02 seconds, the trail delays and did not show from the starting point of the bullet part.
https://gyazo.com/382af40a68cf52a55f24bbb71f9928a1

Is this the Roblox trail problem or I did anything else wrong?

I think this could be resolved if you delay by at least one frame before moving the bullets. That does mean you need to render bullets on a per-client basis, unfortunately.

Effectively what’s happening is the part that the trail is on has moved to the position in front of the gun before it had a chance to render at its starting position. Trails render a new segment every frame if I’m not mistaken. If you create the bullet, wait one frame, then begin your interpolation, it should come out OK.

5 Likes

How do I wait one frame? Using RenderStepped?

Edit:
I used delay() function to wait 0.01 second before starting the tween and it works, but I think waiting one frame should be more efficient

1 Like

You can wait one frame by doing: RunService.RenderStepped:Wait()

3 Likes

In terms of using delay() and spawn(), those use the task system. Both have about a 1/30th of a second delay between calling and actually running the specified function due to how Roblox’s task scheduler works.

I think using RenderStepped:Wait() like @geovanny4567 said is the best way to go.

1 Like