The question above explains the situation. My main question is if there are any performance issues when removing client scripts and adding them back to player guis when needed. For more context, I have set up server script that is in the ServerStorage with a client script as its child. I add the client script into the player’s gui and a remoteevent into the replicated storage, the remote event has a unique name every time it is copied and the client script adjusts to that. Then I run the event from the server to the client. It all works correctly and when I’m done, i destroy the client and remote, and copy it later back into the workplace when I need it again using the server.
I want to know if this has any performance issues or vulnerabilities. Such as too much removing of clients and remotes or possible exploitation. The entire setup works completely fine, I’m just mainly worried if the performance of the game may go down.
It seems convoluted and atypical but aside from that the only real performance concern isthe VM instantiating another fiber and the engine instantiating a Script object, then scheduling it for the task scheduler, which is going to be a bit slower than your usual event call or spawn/defer. If its harmless though, then its harmless. You can be the judge of your own game’s performance.
Creating a remote event with a random name
An exploiter can create a script that listens to new RemoteEvents being created
game.ReplicatedStorage.ChildAdded:Connect(function(child) print(child.Name) end)
Creating and destroying instances can have a compounding performance cost, depending on how frequently and excessively it’s done. If you’re only doing it occasionally, the impact is minimal. However, you should avoid doing it every frame.
There may be issues like duplication or scripts not being created properly when doing this, but you can avoid them by using simple checks. However, I believe the main risk is script compilation delay.
Scripts inserted into PlayerGui are compiled upon insertion. This can become a major issue if you rely on immediate execution right after insertion, due to timing problems. Personally, I wouldn’t use this approach frequently, or I would add checks to handle such cases.
So I should be fine as long as I don’t put and remove scripts too fast. I can have this setup occasionally happen without any major performance problems?