|
| 18 Mar 2017 10:38 AM |
So I just started learning how to script and my code is horrid. Right now I am working on a script that will make its parent "lay eggs" as in dropping a round object with a script in it right below itself. I intend for the "egg" to hatch into whatever it's parent is after a set amount of time.
Egg = Instance.new("Part", Workspace) Egg.Shape = Enum.PartType.Ball Egg.Size = Vector3.new(2, 2, 2) Egg.Material = "Foil" Egg.BrickColor = BrickColor.White() Egg.Name = Egg while true do Instance.new("Egg", Workspace) wait(5) end
I had it working somewhat before so that it would spawn the Egg object somewhere beside it, but then Roblox Studio decided to crash and now the 7th line of code gives an error, right now the only thing this will do is spawn the Egg when the game starts, (Which I did not want to to because it is supposed to spawn the Egg after 5 seconds) but I want it to keep spawning eggs every 5 seconds.
The main thing I am trying to figure out is how to create an object with code, ## well ## code that creates code in the object that it is creating. |
|
|
| Report Abuse |
|
|
6191X
|
  |
| Joined: 21 Jan 2017 |
| Total Posts: 119 |
|
|
| 18 Mar 2017 10:46 AM |
Egg = Instance.new("Part", Workspace) Egg.Shape = Enum.PartType.Ball Egg.Size = Vector3.new(2, 2, 2) Egg.Material = "Foil" Egg.BrickColor = BrickColor.White() Egg.Name = Egg while true do egg.Parent = workspace wait(5) end |
|
|
| Report Abuse |
|
|
00doggie
|
  |
| Joined: 30 Jul 2009 |
| Total Posts: 337 |
|
|
| 18 Mar 2017 10:50 AM |
| perhaps you could have a copy of the script in the ReplicatedStorage and you could just do local clone = ##################################### clone.Parent = Egg just put that stuff in your script (make sure you put the script in replicated storage) |
|
|
| Report Abuse |
|
|
00doggie
|
  |
| Joined: 30 Jul 2009 |
| Total Posts: 337 |
|
|
| 18 Mar 2017 10:52 AM |
| if you dont know what I mean with the tags, I can elaborate, but I think even with tags you get the idea |
|
|
| Report Abuse |
|
|
CrniOrao
|
  |
| Joined: 12 Oct 2008 |
| Total Posts: 2274 |
|
|
| 18 Mar 2017 11:16 AM |
function SpawnEgg() Egg = Instance.new("Part", Workspace) Egg.Shape = Enum.PartType.Ball Egg.Size = Vector3.new(2, 2, 2) Egg.Material = "Foil" Egg.BrickColor = BrickColor.White() Egg.Name = "Egg" end
while true do wait(5) SpawnEgg() end |
|
|
| Report Abuse |
|
|
|
| 18 Mar 2017 11:24 AM |
| Thanks! So how do I create the Egg so that it has script in it rather then just a being a plain part? |
|
|
| Report Abuse |
|
|
Talji
|
  |
| Joined: 02 Mar 2017 |
| Total Posts: 7 |
|
|
| 18 Mar 2017 12:33 PM |
| clone a union cframe it to torso and unachor the union |
|
|
| Report Abuse |
|
|
|
| 18 Mar 2017 12:44 PM |
| I'm new to scripting, so I don't really understand much of that, why would it be anchored in the first place? |
|
|
| Report Abuse |
|
|