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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 08 Feb 2013 |
| Total Posts: 2522 |
|
| |
|
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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 27 Oct 2012 |
| Total Posts: 1824 |
|
|
| 29 Dec 2012 10:38 PM |
| I've never seen that ChildAdded event. |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|