Couldn’t create a separate function for each instance

The function I want is:

- The player will create a machine gun.

- Each machine gun will have a duration (lifetime) when it’s created.

- The machine gun should be destroyed when its time is over.

I couldn’t create a separate function for each instance.When I spawn only one machine gun, it works fine. But if I spawn more than one, it doesn’t work as expected.

Video showing the functionality I need: https://webmshare.com/play/dGjGx

Events for creating:

https://preview.redd.it/0gdiu8bgto6f1.png?width=918&format=png&auto=webp&s=0de1dc43c9672827876014af98ffcf7b0bea6854

Event for destroying:

https://preview.redd.it/n3o9takhto6f1.png?width=1911&format=png&auto=webp&s=45657fc793af112887ad37fb7858d4433e696680

Video showing the error: https://webmshare.com/play/VbLbj

Posted Jun 13, 2025, 12:25 PM UTC

43
Loading comments…