Instance.new() lag causing problem

Hey, i would like to optimise my game and then i found this thread

Does this also count for when creating decals, meshes, sounds and welds ? ?
thats what i mostly use with instance.new()

i wasnt able to find it in the orginal post only abou the valuves that someone tried it with intvalue and string and seems like there wasnt issues however what about decals and meshes

also animations i forgot to ask animations too

It’s everything and not too hard to fix. It should only effect you though if you create tons of new instances really quickly such as in a loop.

Anything in the explorer window is an instance (anything you can insert with the Instance.new function is an instance). Instances are just “objects”.

Partially unrelated but there are some objects that are not Instances, like RBXScriptSignals.

i mean i have a gun script and if you shoot a player really often it creates everytime decals using instance.new() to make blood patterns on the player

Generally, it’s best to set all the properties before setting the Parent.

1 Like

ok i just done that, these old script are horrible

Just don’t use the second arguement for Instance.new?

Just store it somewhere and then use :Clone()

wait tahts it ?, Just not use the second argument on instance.new ?

1 Like

Yes, it is for everything. If you wanted to add a Part, do this instead:

local Part = Instance.new("Part")
Part.Parent = workspace
1 Like

I am pretty sure it’s fine to use the second argument IF you aren’t modifying any properties.

That’s 1 case. Another case where you can use the second argument is when you are parenting it to part which either itself doesn’t have a parent or the has an ancestor that doesn’t have a parent (other than game), this is because you will still just be changing bytes inside the memory.

that post is from 2016 im pretty sure they fixed that

i hope so.

Long storys short meaning ive removed the second argument if there was one and then set it last to parent and also if a CFrame wasnt determined i used CFrame.new() and if a size wasnt determined i also did Vector3.new()