Queliux
|
  |
| Joined: 13 Feb 2011 |
| Total Posts: 341 |
|
|
| 25 May 2014 09:10 AM |
It's such a simple script and there is nothing in the output and I have tried a loop and checked all the parents but this script isn't working.... If you could help it will be a big help. Thanks.
if script.Parent.Throttle == 1 or script.Parent.Throttle == -1 then script.Parent.Parent.ENGINESOUND.Sound:Play() elseif script.Parent.Throttle == 0 then script.Parent.Parent.ENGINESOUND.Sound:Stop() end |
|
|
| Report Abuse |
|
|
|
| 25 May 2014 09:41 AM |
| script.Parent.Throttle.Value |
|
|
| Report Abuse |
|
|
Queliux
|
  |
| Joined: 13 Feb 2011 |
| Total Posts: 341 |
|
|
| 25 May 2014 09:52 AM |
| Why value? There is no value in throttle.. Throttle is a member of VehicleSeat it doesn't have any children. |
|
|
| Report Abuse |
|
|
|
| 25 May 2014 09:54 AM |
| Oh sorry I thought Throttle was NumberValue XD |
|
|
| Report Abuse |
|
|
|
| 25 May 2014 09:55 AM |
Try this
if script.Parent.Throttle ~= 0 then script.Parent.Parent.ENGINESOUND.Sound:Play() else script.Parent.Parent.ENGINESOUND.Sound:Stop() end
|
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 25 May 2014 09:58 AM |
| Hook it up to a changed event so it'll check everytime the throttle changes |
|
|
| Report Abuse |
|
|
|
| 25 May 2014 09:59 AM |
script.Parent.Touched:connect(function() if script.Parent.Throttle ~= 0 then script.Parent.Parent.ENGINESOUND.Sound:Play() else script.Parent.Parent.ENGINESOUND.Sound:Stop() end end) |
|
|
| Report Abuse |
|
|
Queliux
|
  |
| Joined: 13 Feb 2011 |
| Total Posts: 341 |
|
|
| 25 May 2014 10:09 AM |
| @128 Gonna try that now. @warspy Nope :/ |
|
|
| Report Abuse |
|
|
Queliux
|
  |
| Joined: 13 Feb 2011 |
| Total Posts: 341 |
|
| |
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 25 May 2014 10:17 AM |
function Things_Change(Value) --do things end
script.Parent.Changed:connect(Things_Change) |
|
|
| Report Abuse |
|
|
Queliux
|
  |
| Joined: 13 Feb 2011 |
| Total Posts: 341 |
|
|
| 25 May 2014 10:29 AM |
| @128 Okay it works but it stops and starts a lot because it starts the function whenever something in VehicleSeat changes so if you turn and your throttle is still 1 or -1 then it will stop then when you stop turning it starts again, how can I fix this? |
|
|
| Report Abuse |
|
|
Queliux
|
  |
| Joined: 13 Feb 2011 |
| Total Posts: 341 |
|
|
| 25 May 2014 10:30 AM |
The script:
function Things_Change(Value) if script.Parent.Throttle == 1 or script.Parent.Throttle == -1 then script.Parent.Parent.ENGINESOUND.Sound:Play() elseif script.Parent.Throttle == 0 then script.Parent.Parent.ENGINESOUND.Sound:Pause() end end
script.Parent.Changed:connect(Things_Change) |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
| |
|
Queliux
|
  |
| Joined: 13 Feb 2011 |
| Total Posts: 341 |
|
| |
|
|
| 25 May 2014 11:37 AM |
So this obviously works;
script.Parent.Touched:connect(function() if script.Parent.Throttle ~= 0 then script.Parent.Parent.ENGINESOUND.Sound:Play() else script.Parent.Parent.ENGINESOUND.Sound:Stop() end end)
Now with a debounce....
DBTime = 5 --Time for debounce --Below works on its own DB = false script.Parent.Touched:connect(function() if DB == false then if script.Parent.Throttle ~= 0 then script.Parent.Parent.ENGINESOUND.Sound:Play() elseif script.Parent.Parent.ENGINESOUND.Sound:Stop() end DB = true wait(DBTime) end end) |
|
|
| Report Abuse |
|
|
Queliux
|
  |
| Joined: 13 Feb 2011 |
| Total Posts: 341 |
|
|
| 25 May 2014 11:54 AM |
| The touched thing doesn't work but I tried the DB with the script that does work but it now only makes the sound for 10 seconds which is the db time... |
|
|
| Report Abuse |
|
|
|
| 25 May 2014 01:30 PM |
Oops XD I failed. I meant to use Changed not Touched
Just replace Touched with Changed. |
|
|
| Report Abuse |
|
|
|
| 25 May 2014 01:31 PM |
Here
DBTime = 5 --Time for debounce --Below works on its own DB = false script.Parent.Changed:connect(function() if DB == false then if script.Parent.Throttle ~= 0 then script.Parent.Parent.ENGINESOUND.Sound:Play() elseif script.Parent.Parent.ENGINESOUND.Sound:Stop() end DB = true wait(DBTime) end end) |
|
|
| Report Abuse |
|
|
Queliux
|
  |
| Joined: 13 Feb 2011 |
| Total Posts: 341 |
|
|
| 25 May 2014 01:37 PM |
| Now when I stop it waits until the audio is over and if I go again the sound doesn't come up. |
|
|
| Report Abuse |
|
|
|
| 25 May 2014 01:42 PM |
Sorry found my error...
DBTime = 5 --Time for debounce --Below works on its own DB = false script.Parent.Changed:connect(function() if DB == false then if script.Parent.Throttle ~= 0 then script.Parent.Parent.ENGINESOUND.Sound:Play() elseif script.Parent.Parent.ENGINESOUND.Sound:Stop() end wait(DBTime) DB = true end end) |
|
|
| Report Abuse |
|
|
Queliux
|
  |
| Joined: 13 Feb 2011 |
| Total Posts: 341 |
|
|
| 25 May 2014 01:46 PM |
| Nope, same thing happens... |
|
|
| Report Abuse |
|
|