So I have recently been thinking about how to optimize scripts so it won’t be so laggy and I have a couple of questions starting off with my first one is how does GetPropertyChangedSignal Works? does it check like every frame like renderstepped if the property changed or does it just exactly know when it changes and doesn’t do like a while wait() do end scanning each frame if the property changed cause wouldn’t it cause a major amount of lag if the script is really big
my next question is let us say I have a Button1Down function and once it is ran
local vartest = true
while vartest == false then
print("Vartest equals to false")
end
and let us say the button1down event is touched multiple times by a bunch of players wouldn’t this cause lag? and how would I fix this problem I believe this is called a memory leak
Thanks to anyone that replies to this post I just really want to get more into detail on how to get my games optimized
GetPropertyChangedSignal() is basically like :Changed(), except it works for a specific property instead of checking if any one property changes. If anything, it should be less laggy than :Changed()
I know that it is instantaneous, but I don’t believe it is repeatedly looking (or looping) to check if it has changed. It is more of a signal, so it knows when it changes at all.
I don’t much about memory leaks, but I believe that Button1Down is a client based function, so it shouldn’t generally cause any global lag. The lag you experience should be based on the spec of your computer, not the server. The only way I could see it cause server lag is if the function uses a RemoteEvent or Function, and a bunch of players are using that RemoteEvent/RemoteFunction and it uses a lot of data.
local vartest = true
while vartest == false then
print("Vartest equals to false")
-- please don't make a loop that doesn't yield, your studio will crash
end