Can creating value and destroying them cause lags

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Knowing if I destroy a value repeatedly can cause lag or not, especially the lifetime is short
  2. What is the issue? Include screenshots / videos if possible!
    To keep it in short, I want to make stun,usually I parent it inside a folder and it will check if there’s any stun, if there is then return. But I remember that destroying can cause lags if you do too much and the stuns are really short so it can literally destroy at anytime.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Yes I did look for them, but I have some trust issues inside me so I am not sure if I should do the stun system like that.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
1 Like

Well. depends how often they get stunned a reasonable amount of objects getting destroyed is about 500 per second.

Why would you want to destroy the value? Also is it not possible to just use a boolean for this instead of a value since you are just checking if there is a stun?

You can set it to true/false if you want to disable it or enable it.

What do you mean by return? Do you mean return stunning the player if there is a stun? Also, is the stun that you are checking for in a module script?

Your post is very vague right now but I can answer the question in the title:
No. However this is very inefficient and should just be stored in memory so it can be reused again. Unless you are doing it only a few times then sure you can create and destroy it.

NPC’s are a great example of something that can be created and destroyed since it’s done very few times.

It’s something like this: My melee script will check if there’s a stun value inside, if it does then it will not allow the player to hit. And also I would want to do that because I don’t know how to make it so the stun stacks up

i didn’t understood what are you trying to achieve but:

• yes, creating INSTANCES is laggy

• you can use attributes which are fasters and acts like instance values

• unless you create multiple instances per seconds, you should be fine (keep in mind if you are developing a multiplayer game, i dont recommend to do this)

• if you truly need to create multiple instances per second, destroy the parts later in the future (like 2 seconds)

So in conclusion:Yes creating values and deleting them as for making stun system can cause lag. I kind of fixed my stun system so I used attributes now