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 » Scripting Helpers
Home Search
 

Re: How can I make a script

Previous Thread :: Next Thread 
RoScripts is not online. RoScripts
Joined: 27 Oct 2012
Total Posts: 1824
29 Dec 2012 10:22 PM
How can I make a script that searches lighting until it finds a model? When it finds that model I would like the script to clone a script located in lighting and move it into that model.

Any help?
Report Abuse
sweis12 is not online. sweis12
Joined: 08 Feb 2013
Total Posts: 2522
29 Dec 2012 10:24 PM
If you already have a script that searches for it, add a timer to the top like 1 second delays. Then add the loop to the bottom.
Report Abuse
RoScripts is not online. RoScripts
Joined: 27 Oct 2012
Total Posts: 1824
29 Dec 2012 10:24 PM
What is the function used to add a loop to the bottom?
Report Abuse
sweis12 is not online. sweis12
Joined: 08 Feb 2013
Total Posts: 2522
29 Dec 2012 10:28 PM
I will look that up. BRB
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
29 Dec 2012 10:30 PM
"How can I make a script that searches lighting until it finds a model? When it finds that model I would like the script to clone a script located in lighting and move it into that model."

game.Lighting.ChildAdded:connect(function(child)
if child.Name == "Model" then
script:Clone().Parent = child
end
end)

ChildAdded event
Report Abuse
sweis12 is not online. sweis12
Joined: 08 Feb 2013
Total Posts: 2522
29 Dec 2012 10:31 PM
Miz, that would work better than what I would have done lol.
Report Abuse
RoScripts is not online. RoScripts
Joined: 27 Oct 2012
Total Posts: 1824
29 Dec 2012 10:34 PM
@Miz

Does that keep repeating?

And I would just like to know what line do I need to add if I wanted to add a script inside the model. Would it be too hard?
Report Abuse
RoScripts is not online. RoScripts
Joined: 27 Oct 2012
Total Posts: 1824
29 Dec 2012 10:38 PM
I've never seen that ChildAdded event.
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
29 Dec 2012 10:41 PM
"Does that keep repeating? "

You don't want it to keep repeating. That'll cause more lag.

Using my script runs right when a child is added in Lighting.

Using a while loop(or some kind of other loop) will constantly check the item, making the program run everytime. Giving the interpreter no time to take a break.

Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
29 Dec 2012 10:44 PM
> Using a while loop(or some kind of other loop) will constantly check the item, making the program run everytime. Giving the interpreter no time to take a break.

while true do
child = Game.Lighting.ChildAdded:wait()
if child.Name == "Model" then
script:Clone().Parent = child
end
end
Report Abuse
RoScripts is not online. RoScripts
Joined: 27 Oct 2012
Total Posts: 1824
29 Dec 2012 10:44 PM
Oh I see.

Would it be too hard to add a line that instead of putting the script in the model, put the script in a tool which is located in the model?
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
29 Dec 2012 10:46 PM
ToolName = "ToolName"

game.Lighting.ChildAdded:connect(function(child)
if child.Name == "Model" then
script:Clone().Parent = child[ToolName]
end
end)
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
29 Dec 2012 10:56 PM
You know... I like how you correct me and then the next post you say on this forum has to do with exactly with what my code did.
Report Abuse
RoScripts is not online. RoScripts
Joined: 27 Oct 2012
Total Posts: 1824
29 Dec 2012 10:58 PM
It's not working :c

ToolName = "DeleteTool"
script = Game.Lighting["Deleter"]

Game.Lighting.ChildAdded:connect(function(child)
if child.Name == "BuildToolsModel" then
script:Clone().Parent = child["DeleteTool"]
end
end)

Is there anything wrong there? This is running on a Private Build Server. Is there anything wrong?
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
29 Dec 2012 11:04 PM
> I like how you correct me and then the next post you say on this forum has to do with exactly with what my code did.

I didn't say what I posted was better or more efficient. What I posted was proving what you said false. What I posted didn't really have anything to do with the thread.
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
29 Dec 2012 11:14 PM
"You know... I like how you correct me"

I know. But posting it was useful. Gives me more information to compile in my head.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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