Whilst trying out Parallel Lua, I ran into some unsafe functions and was wondering if there are any other alternatives. Here’s my code:
workspace.Part.ClickDetector.MouseClick:Connect(function()
local bindable = Instance.new("BindableEvent")
bindable.Parent = script.Parent
bindable.Event:ConnectParallel(function()
for i,v in pairs(game.Players.LocalPlayer.PlayerGui.PixelContainment:GetChildren()) do
task.wait()
v:Destroy()
end
end)
bindable:Fire()
end)
The goal is to multi-thread destroying instances (Frames, 2500 of them…) simply for the speed of it. Running this synchronized, as you might be able to assume, takes a little bit especially since the task.wait() is there to keep my computer from exploding.
Are there any alternatives to running Destroy() within Parallel Lua, or even just making Destroy() faster running it synchronously?
I noticed you are destroying all children inside a certain Instance. You can use the Instance:ClearAllChildren() to accomplish this faster without using task.wait().
using a BindableEvent to destroy frames I imagine is secure anyways with a BindableEvent, even though not as secure as something else.
Something else, such as not using a BindableEvent at all, is currently the most secure way. I wouldn’t expect a BindableEvent to be insecure at all on the server, but on the server, which is already secure, is not the most secure way of execution. I wouldn’t worry about this at all because it’s like one in a trillion that it could be hacked.
I didn’t realize by ‘safe’ you were inferring to ‘thread safety’, I thought you were referring to garbage collection, parent locking, disconnecting event/signal connections etc. I should have read the thread’s subject beforehand.