So im making a fnaf tycoon i started it last night and i need help with a :Destroy() script and if you could help me with this right here yea so please help.
Here the script
**local Freddy = game.Workspace:WaitForChild(“Freddy”)
local part = script.Parent
You actually don’t need to pass any parameters in the Destroy() function! In addition, you may want to check out Debris. (It’s a more up-to-date destroy service!)
Ok um i dont know how to use Debris im actually really bad at scripting so i have barely any scripting experience so if you want to check out my games you can there on this profile and i also just learned these games from the wiki so im pretty bad so please give me an example
Yep, it only destroys it once. (Expected behavior!)
If you’d like it to destroy multiple items or things, copy this and paste it into the script that destroys multiple things:
local Debris = game:GetService("Debris") -- Delete that if it's already a service in the script.
Debris:AddItem(ItemHere, Time) -- Change ItemHere to the item you want to destroy, and Time to the time you'd like to elapse before it gets destroyed!
Debris:AddItem(ItemHere, Time) -- Change ItemHere to the item you want to destroy, and Time to the time you'd like to elapse before it gets destroyed!
Debris:AddItem(ItemHere, Time) -- Change ItemHere to the item you want to destroy, and Time to the time you'd like to elapse before it gets destroyed!
Destroy and Debris do the same thing except for Debris is scheduled to fit your lifetime parameter. Could you show me any posts about Debris being more up-to-date?
It actually is more intricate than things being scheduled to be destroyed.
The difference lies within the function/service itself. Destroy will error if the object(s) are already destroyed, which can be a problem. (Terminating the rest of the code.) For this reason, it is advised to use Debris, which, unlike Destroy, will not error and will continue the code if the object is already destroyed.
In addition, as stated, you can wait a certain amount of time within one line, rather than 2 or 3 lines, which can be a nice perk in the long run.
I hope this clears it furthermore why Debris is often better than Destroy.
There’s no such thing as an object “not being found”. Destroy can never error unless an object’s parent is locked to something other than nil.
Never said it’s bad to use Debris, just that it’s not the “newer and improved way to destroy”, it’s just a destroy scheduler. So if you need to destroy something after 5 seconds, yeah just use Debris.
This actually makes no sense. You usually use Destroy when you want something to be gone immediately. Debris is only useful when you want to specifically destroy something after a certain, fixed, amount of time. Basically, it’s a replacement for task.delay(5, x.Destroy, x).