|
| 19 Apr 2014 03:27 PM |
I have a pretty complicated problem. I am creating a game that depends on xLEGOx's cart ride tracks and cart. The carts automatically regen. The problem I am having is that I am trying to make a part of the rail that when touched by a cart, the cart will stop. The script for this cart is:
touched = false
function onTouched(hit) if not touched then touched = true game.Workspace.Cartlol3.Speed.Value=0 wait(11) game.Workspace.Cartlol3.Speed.Value=15 wait(0.1) game.Workspace.Cartlol3.CanCollide=false touch = false end end script.Parent.Touched:connect(onTouched)
This script works on the original Cartlol3. However, once the cart is cloned by my automatic regen script, the clones will not stop when they touch the stopping part. The regen script is a standard cloning thing. Does anyone have any idea why The original cart is the only one to stop?
|
|
|
| Report Abuse |
|
|
| |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 19 Apr 2014 03:55 PM |
(You should of done touched = false but that's beside the point)
Your problem is that you are indexing the first one it finds in workspace instead of actually indexing the one that touches it. |
|
|
| Report Abuse |
|
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 19 Apr 2014 04:00 PM |
You're going to have to structure the model in a way that whatever touches it, you know the amount of parents you are going to need to get to the location where the value "Speed" is. Or you could do it inefficiently.
Anyway, it might be like: hit.Parent.Parent.Parent.Speed.Value = blah |
|
|
| Report Abuse |
|
|
|
| 19 Apr 2014 04:03 PM |
| So the mroe cartsthere are the more parents I put? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 19 Apr 2014 04:05 PM |
No.
If your cart hierachy looks like this:
-cart --speed --parts...
Then you only need 1 parent, but if the parts are in another model, 2, etc. |
|
|
| Report Abuse |
|
|
|
| 19 Apr 2014 04:10 PM |
| But wouldn't the system still look for the first cart because all the carts have the same amount of parents? |
|
|
| Report Abuse |
|
|
|
| 19 Apr 2014 04:11 PM |
| Is this script even in the cart? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 19 Apr 2014 04:12 PM |
OP, before scripting please try to understand what the Parent property even is.
|
|
|
| Report Abuse |
|
|
|
| 19 Apr 2014 04:14 PM |
| Can you give me the script please? |
|
|
| Report Abuse |
|
|
| |
|
|
| 19 Apr 2014 04:27 PM |
Look at Cnts post. Go along now, Do your research. |
|
|
| Report Abuse |
|
|
|
| 19 Apr 2014 04:29 PM |
Can you please just tell me? I am really lazy. |
|
|
| Report Abuse |
|
|
|
| 19 Apr 2014 04:35 PM |
http://wiki.roblox.com/index.php?title=Parent Laziness is not a valid excuse. If you want this you`ll have to work for it. One does not simply skip the basics. |
|
|
| Report Abuse |
|
|
|
| 19 Apr 2014 04:37 PM |
| Do you even know how to script? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 19 Apr 2014 04:41 PM |
| Says the one who wants everything done for him... |
|
|
| Report Abuse |
|
|
|
| 19 Apr 2014 04:42 PM |
| Anyway, I know what parents are. I don't know how to use them in this situation. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 19 Apr 2014 04:44 PM |
| When a piece of the car touches the brick, the brick will go up some and then speed will be there... |
|
|
| Report Abuse |
|
|
|
| 19 Apr 2014 04:48 PM |
| Sorry, I still don't get you. |
|
|
| Report Abuse |
|
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 19 Apr 2014 04:53 PM |
Scenario:
Cart wheel touches part, cart wheel is located in cart.wheels. hit.Parent.Parent.Speed (wheel.Parent = wheels.Parent = cart) |
|
|
| Report Abuse |
|
|
|
| 19 Apr 2014 04:55 PM |
| I get what you are saying now, but how do I make this in a touched script? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 19 Apr 2014 04:56 PM |
| I basically already did that line |
|
|
| Report Abuse |
|
|