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
 

What's wrong?

Previous Thread :: Next Thread 
Queliux is not online. 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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
25 May 2014 09:41 AM
script.Parent.Throttle.Value
Report Abuse
Queliux is not online. 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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
25 May 2014 09:54 AM
Oh sorry I thought Throttle was NumberValue XD
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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 is not online. 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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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 is not online. Queliux
Joined: 13 Feb 2011
Total Posts: 341
25 May 2014 10:09 AM
@128 Gonna try that now. @warspy Nope :/
Report Abuse
Queliux is not online. Queliux
Joined: 13 Feb 2011
Total Posts: 341
25 May 2014 10:13 AM
@128 Kinda stuck on that.
Report Abuse
128GB is not online. 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 is not online. 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 is not online. 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 is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
25 May 2014 10:33 AM
Add a debounce
Report Abuse
Queliux is not online. Queliux
Joined: 13 Feb 2011
Total Posts: 341
25 May 2014 10:46 AM
Where should I put it?
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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 is not online. 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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
25 May 2014 01:30 PM
Oops XD I failed. I meant to use Changed not Touched


Just replace Touched with Changed.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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 is not online. 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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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 is not online. Queliux
Joined: 13 Feb 2011
Total Posts: 341
25 May 2014 01:46 PM
Nope, same thing happens...
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