Would this cause lag or error?

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!

I would like to ask questions whether this is good or very bad.

  1. What is the issue? Include screenshots / videos if possible!
    My issue is that I lack knowledge.

  2. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I couldn’t see to find any similar.

Okay so, I would like to ask a simple question

The script shown below, would it not cause problems to my game if I have similar scripts like these in different scripts?

For example, I could have a similar script shown below in 5 different scripts, would these not cause problems or lag?

local run = game:GetService("RunService")

local click = false


run.Heartbeat:Connect(function()
    if click == true then
          frame.Size = Udim2.fromScale(depends, depends)
          click = false
    end
end)

I know it’s a simple question, but it’s a big issue for me, thank you very much for responding!

It shouldn’t, but why not just use a loop for it?

1 Like

I dont think so, but you should use game:GetService("UserInputService").InputBegan instead.

1 Like

Did you read the code he provided? There is nothing about input

He should use a loop, no need to give him basically the same answer :-1:

May I ask why I should use a loop?

Loops are inefficient since its basically running the same script over again when you’re not even clicking, which is why using InputBegan is more efficient, it only runs the code when the game registers an input (like a click in this case).

1 Like

How do you know his “click” is meant for clicking, he didn’t provide that. A loop will only work if the value is true or false, just like he wants it to

1 Like

The variable is clearly named “click”, and it seems like a ui tweens when the variable is set to true, what else would you expect for the variable to be used for?