generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: How to make script within a part created by script?

Previous Thread :: Next Thread 
bludud1234 is not online. bludud1234
Joined: 29 May 2010
Total Posts: 43
19 Mar 2017 12:24 PM
I was wondering how to make a part the has been created by script have script within it, I'll post the part that I want script in below.



function SpawnEgg()
Egg = Instance.new("Part", Workspace)
Egg.Shape = Enum.PartType.Ball
Egg.Size = Vector3.new(1, 1, 1)
Egg.Material = "Foil"
Egg.BrickColor = BrickColor.White()
Egg.Name = "Egg"
end

while true do
wait(5)
SpawnEgg()
end
Report Abuse
LaeMVP is online. LaeMVP
Joined: 24 Jun 2013
Total Posts: 4416
19 Mar 2017 12:29 PM
You would just Instance a script in then parent it to the egg, something like:

local eScript = Instance.new("Script", Egg)
Report Abuse
Real_Spooky is not online. Real_Spooky
Joined: 23 Oct 2013
Total Posts: 3149
19 Mar 2017 12:37 PM
No, because then you couldn't have any content in the script.

local ds = DesiredScript:Clone()
ds.Parent = Egg
ds.Enabled = true

where DesiredScript, is of course, the desired script.
Report Abuse
bludud1234 is not online. bludud1234
Joined: 29 May 2010
Total Posts: 43
19 Mar 2017 12:37 PM
I'm sorry, I forgot to mention that I am extremely new to scripting, so I do not understand what an eScript is, and I do not fully understand the concept of local.
Could you or someone else explain it to me like I am someone with a mental deficiency?
Report Abuse
Real_Spooky is not online. Real_Spooky
Joined: 23 Oct 2013
Total Posts: 3149
19 Mar 2017 12:39 PM
Local just means it will go out of scope once the function exits.

if you had:

function x()
local e = true
end

The variable e would not exist after x() finishes, so no more memory is taken up.
and eScript is just a plain old variable.
Report Abuse
LaeMVP is online. LaeMVP
Joined: 24 Jun 2013
Total Posts: 4416
19 Mar 2017 12:40 PM
You can put a script into the part, but it will be useless.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image