Help with an RPG projectile

Hi! I’m currently working on a decently popular army game and am encountering an error with a projectile module script for an RPG.

It all works fine, until the player dies while an RPG they shot is in the air or in the process of exploding.

The issue is that RunService won’t continue running after that player has died, below you can find a code example.

local t = 1
t = distance/projectile.maxVelocity

local nt = 0;

while (nt < t*2) do
nt = nt + rs:Wait(); --rs = RunService


There hasn’t been much that I tried yet, although there isn’t much I can try.
I am hoping for someone who is experienced with RunService and can help walk me through what went wrong. If it helps, I’ve already looked at the devforum for similar issues along with docs about RunService and didn’t find anything.

Thanks in advance!

1 Like

Have you tried using a normal wait and see how it affects the RPG?

A normal wait doesn’t work in this situation, as explained in the post it uses the rs:Wait() time so it doesn’t overshoot or undershoot the target. Using a normal wait you would need to supply a time, or no time at all, which isn’t ever changing.