|
| 14 Jul 2011 01:02 PM |
Right now I'm trying to recreate the Giant Drop. My current components that are in the system is Car1 (BodyGyro and BodyVelocity), Lock (No inserted objects), Thruster (BodyThrust and BodyVelocity), and finally, Switch (ClickDetector, Decal, and Script). So far, everything was working fine until I wanted to make the Giant Drop noob proof, so I tried adding a debounce thing, whatever that means. Got the idea off of a cannon because of the reloading. So far, I have this:
s = script g = game.Workspace local Car = s.Parent.Parent.Car1 local Thruster = s.Parent.Parent.Thruster local Lock = s.Parent.Parent.Lock local debounce = false -------------------------
function ride()
--------Start print 'Start' Car.BodyVelocity.velocity = Vector3.new(0, 3, 0) wait(5) Car.BodyVelocity.velocity = Vector3.new(0,20,0) wait(20) Car.BodyVelocity.velocity = Vector3.new(0,1,0) wait(5)
-------Up Top print 'Stop' Car.BodyVelocity.velocity = Vector3.new(0,0,0) wait (17) print '3' wait(1) print '2' wait(1) print '1' wait(1) print 'DROP!'
-------The Drop Lock.CanCollide = false Lock.Transparency = 1
wait(3) print 'Thrusters engaged' Thruster.BodyThrust.force = Vector3.new(0,500,0)
wait(1) print 'Thrusters disengaged. Velocity taking over' Thruster.BodyThrust.force = Vector3.new(0,0,0) Thruster.BodyVelocity.maxForce = Vector3.new(1000e+010, 1000e+010, 1000e+010) Thruster.BodyVelocity.velocity = Vector3.new(0,-2,0)
wait(5) print 'Velocity disengaged' Thruster.BodyVelocity.velocity = Vector3.new(0,0,0)
-------The Reset wait(20) print 'Reseting...' Car.BodyVelocity.velocity = Vector3.new(0,-2,0) wait(50)
Lock.CanCollide = true Car.BodyVelocity.velocity = Vector3.new(0,0,0) print 'Cycle Complete.' end
function OnClicked()
if debounce == false then print 'Click detected. System Start-up' debounce = true wait(10) ride() switch.BrickColor = BrickColor.new(21)
wait(160)
debounce = false switch.BrickColor = BrickColor.new(37)
end end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
The prints are in there so I can record what the ride is doing at that current section. However, that is not the problem. The problem is that once I click on the switch, the Output window tells me "attempt to call a nil value." Because I'm still new to the scripting, I have no idea what that means. Could someone please find the problem and tell me what to do? |
|
|
| Report Abuse |
|
|
beeep100
|
  |
| Joined: 16 May 2009 |
| Total Posts: 168 |
|
|
| 14 Jul 2011 01:06 PM |
| Switch doesnt excist. You need to put at the start of the script local switch = whatever you weant it to be. |
|
|
| Report Abuse |
|
|
|
| 14 Jul 2011 01:15 PM |
| I added "local switch = s.Parent.Parent.Switch" in two different spots using trial and error. At the way top, I get nothing, not even in the output bar, but when after "g = game.Workspace", I get the nil answer again. Is there a certain place the local switch needs to be? |
|
|
| Report Abuse |
|
|
beeep100
|
  |
| Joined: 16 May 2009 |
| Total Posts: 168 |
|
|
| 14 Jul 2011 01:22 PM |
| Well, yes you have to have a tag outside a function. But do you mean youre script does nothing if you place it a the top? |
|
|
| Report Abuse |
|
|
|
| 14 Jul 2011 01:27 PM |
| Yep. It does absolutely nothing. Nothing in output shows up, the cart stays where its at, nothing at all. |
|
|
| Report Abuse |
|
|
beeep100
|
  |
| Joined: 16 May 2009 |
| Total Posts: 168 |
|
|
| 14 Jul 2011 01:31 PM |
Try adding a print to your Onclicked function and see where it goes wrong.(I just randomly came up with this idea.) For example Try1:
function OnCliked() print 'blah blah' (rest of script) end end end
Try2: function OnClicked (one line of script) print 'blah blah' (rest of script)
ect.
If it doesnt show up one time then you have your culprit line. (Im not a very good scripter, I cant see any big problems that well.)
|
|
|
| Report Abuse |
|
|
beeep100
|
  |
| Joined: 16 May 2009 |
| Total Posts: 168 |
|
|
| 14 Jul 2011 01:32 PM |
| Forget that. You already have one. I think its something to do with Debounce. |
|
|
| Report Abuse |
|
|
beeep100
|
  |
| Joined: 16 May 2009 |
| Total Posts: 168 |
|
|
| 14 Jul 2011 01:33 PM |
Forget that. You already have one. I think its something to do with Debounce. I hate floodcheck >=( |
|
|
| Report Abuse |
|
|
|
| 14 Jul 2011 01:38 PM |
| Maybe going off of a cannon for the debounce was a bad idea... |
|
|
| Report Abuse |
|
|