Is this a good respawn system for trees?

Hiya, getting back into development here, so excuse my extra stupidity :stuck_out_tongue:

Anyway, I’m working on a tree chopping mechanic and I’m currently figuring out a way to respawn trees once they have been chopped. So I came up with an idea that does techniqually work, however I want to see what you guys think.

When the health of the tree reaches 0, a BindableEvent is fired and then the tree is sent to a folder in ServerStorage. Then, the health of the tree is set back to its original value and then after a set amount of time, it is sent back to the workspace. Thoughts?

image
image
image
image

I would set up an artificial region identified by four vector points. Then I would randomly put a tree into that zone.

1 Like

I think this is good so far, nothing to worry about. For ‘realism’ though, maybe don’t have the tree instantly disappear (only if it does, I can’t really tell) once it’s chopped.

Also are you using metatables? Might be of interest when you want to add more data and functions to your trees.

2 Likes

Yes, the tree does instantly disappear. Not too good at effects and aesthetics.

And no, I don’t use metatables. It’s just a folder in the tree with IntValues. But I’ll be sure to look in to that because I do the same thing for the axe too. I think overtime it will become to cluttered so I’ll be sure to look into it. Thanks!

Woah, smarty pants over here…

Jokes aside, that does sound interesting. Where should I start in terms of making that? Should I use Region3?

I wouldn’t use Rg3 simply because Roblox deprecated it for performance reasons. You can just make a box with 4 points. I would use a metastable object to define a region and simply call a method to do some logic to spawn a tree. I wrote a system similar to this in an uncopylocked game I made a while back.

The code in this isn’t the best but the concept applies.

Old.rbxl (93.8 KB)

1 Like

I also wrote multiple articles on the forums regarding OOP in LUA. I would suggest taking those a look as well as viewing my youtube. I mostly code using the OOP paradigm, its not good in all scenarios but in this one it is.

1 Like