I am creating a button system that whonever the button is used the script will define the button parent as nil,
My doubt is, even the button parent being nil the game will still render it? if there’s too many buttons as parent = nil the performance will be affected or it’s like the Destroy function?
I don’t use Destroy because I use 2 function to buy and the two set the used attribute has true so if I use destroy i’m afraid the game will only execute one function and delete the script before execute the other.
I’m Trying this now but the coroutine simply doesn’t work, it gives the error ServerScriptService.Components.Buttons:124: missing argument #1 to 'wrap' (function expected)
here’s part of the moduleScript
function Buttons:waitanddestroy(Button)
task.wait(3)
Button:Destroy()
end
function Buttons:Sell()
for _, Button in ipairs (CollectionService:GetTagged("Button")) do
if Button:GetAttribute("Used") == true
then
Button.Parent = game:GetService("ReplicatedStorage")
coroutine.wrap(Buttons:waitanddestroy(Button))()
end end
end
If youre talking about performance as in Frames per Second, anything that isnt parented to workspace, or an active ViewportFrame will not be rendered.
If the models are no longer needed, you are better off deleting them, however, if the model is a map for your game, changing its parent to ServerStorage or ReplicatedStorage will stop it from being rendered, therefore keeping the frames up.
Well I can’t use Destroy directly, I need to add a wait but corountine.wrap and task.spawn doen’t work so if changes the parente don’t give any performance error I will only set the parent as nil.
Attempt renaming the function to Buttons_Wait_and_Destroy
However, if Buttons is a module script, i dont know if you can coroutine a function in one, since i dont really use module scripts.