Reduce Frame Drops

Hi! So I’ve scripted a hide players button but when there is a server with about 50 players and every one of them presses it, they get massive Frame Drops.
Code: (I think the full code is not necessary)

    if isInvisible == false then
        isInvisible = true
        --Make them invisible 
        pcall(function() runService:UnbindFromRenderStep("UnInvis") end)
        runService:BindToRenderStep("Invis", Enum.RenderPriority.Camera.Value - 10, changeTransparencyTo1)
        for i = 1, isInvisText:len() do
            textButton.Text = isInvisText:sub(1, i)

It’s probably because I’m binding it to RenderStepped and when 50 people activate this, then it gets pretty laggy. Any ideas on how to “fix” this?

Why are you using RenderStepped when TweenService exists.
Only use RenderStepped if you have to with no alternatives

1 Like

TweenService? How would I use TweenService for that?

It has to make every player invisible (except yourself ofc) even if they reset or a new player joins.

Players.PlayerAdded, Player.CharacterAdded, am i a joke to you

Also dont use : methods on strings, they are 4-5 times slower than doing string.function(str, …) since it has to pass the entire string metatable instead of just a string

1 Like

But Players.PlayerAdded and Player.CharacterAdded can only be used in a ServerScript.

That is not correct, they can indeed be used in local scripts as well. Why wouldn’t it work?