Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there a better way to do this?

Asked by
AZDev 590 Moderation Voter
8 years ago

I am removing each part of the tycoon that the player purchases to have it replaced in the game later. My problem is that I am doing this one by one. This is a tedious task and is taking way to long. Is there a better way?

This is currently what I am doing.

local tycoon = script.Parent.Parent

local dirt = tycoon.Purchases.DirtDropper:Clone()
dirt:Destroy()

local stone = tycoon.Purchases.StoneDropper:Clone()
stone:Destroy()

local copper = tycoon.Purchases.CopperDropper:Clone()
copper:Destroy()

I was thinking of doing local clone = tycoon.Purchases:GetChildren():Clone() This would be a quick way to remove everything but when it came time to purchase an object all the parts would be re-added all at once. Right?

Thanks for the help ahead of time.

0
The script you are showing destroys those objects immediately before they are actually parented to anything. If they all have the same parent, you can call ClearAllChildren on that. 1waffle1 2908 — 8y
0
I can do that. However, if I do that I cannot reparent them one at a time as they are purchased. Am I right? AZDev 590 — 8y
0
What are you using to get the purchased? Like do they touch a part or do they press some type of button? What are you doing to get them purchased? KingLoneCat 2642 — 8y
0
@KingLoneCat They touch a button. AZDev 590 — 8y

1 answer

Log in to vote
0
Answered by
IcyEvil 260 Moderation Voter
8 years ago

You're problem is that, the thing about :Clone() it needs to have a parent as well I create holo commands for groups, and to make the map simulation I have to clone it,

here is an example.

local map = game.ServerStorage.Map
x = map:Clone()
x.Parent = game.Workspace

that was an example, now let me help you out with your problem.

local tycoon = script.Parent.Parent

local dirt = tycoon.Purchases.DirtDropper
x=dirt:Clone()
dirt:Destroy()
-- extra code here for "x"

local stone = tycoon.Purchases.StoneDropper
s = stone:Clone()
stone:Destroy()
-- extra code here for "s"

local copper = tycoon.Purchases.CopperDropper
n = copper:Clone()
copper:Destroy()
--extra code here for "n"

I hope this fixes your problem, Have a nice day!

0
By the way, I left out the ".Parent" portion as you are obviously doing a tycoon, and you need to add more functions or you might need to, I don't know for sure so I left them out, they are easy to add in though. IcyEvil 260 — 8y
0
I know that clones need to have a parent as well. The clones are parented when the player purchases them. Until then they are removed and their parents are nil. I found an alternative solution now. Since your answer is the only one here I will accept it. Thanks for try anyway. AZDev 590 — 8y
Ad

Answer this question