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 » Scripters
Home Search
 

Re: infinite loop for sound pitch

Previous Thread :: Next Thread 
Roblok1 is not online. Roblok1
Joined: 27 Jul 2011
Total Posts: 2019
30 Apr 2016 02:18 AM
what is the best loop to use to sync a sound's pitch to a moving brick? for example, a car?
i just want to know what loop is best and what type of script to run it in.


Report Abuse
Roblok1 is not online. Roblok1
Joined: 27 Jul 2011
Total Posts: 2019
30 Apr 2016 02:59 PM
b1


Report Abuse
brack4712 is not online. brack4712
Joined: 07 Mar 2009
Total Posts: 243
30 Apr 2016 03:05 PM
Why do you need the pitch to change? Unless the car is going 1 million MPH, the sound should be fine. I would put the put the sound into the roof of the car and call it song1.

If you want it to activate on a gui button you would do this.

function onClicked()
game.Workspace.CARNAME.HOODNAME.song1:Play() --too hood for my own good
end

script.Parent.MouseButton1Click:connect(onClicked)

If you want the audio to loop, select looped in the song1 properties.

To create a stop button do this.

function onClicked()
game.Workspace.CARNAME.HOODNAME.song1:Stop() --too hood for my own good
end

script.Parent.MouseButton1Click:connect(onClicked)



Repeat this process add all of the songs to the hood and call the songs song1, song2, song3, etc.


Good luck.
Report Abuse
Roblok1 is not online. Roblok1
Joined: 27 Jul 2011
Total Posts: 2019
30 Apr 2016 03:43 PM
this is not for a song. its for an engine sound. i know that you know that if a car is going 50 mph, the pitch of the engine will not stay the same. it will get higher.

so with that out of the way; what is the best loop to use for a car engine pitch that will not cause lag?


Report Abuse
Roblok1 is not online. Roblok1
Joined: 27 Jul 2011
Total Posts: 2019
30 Apr 2016 10:47 PM
b2


Report Abuse
Roblok1 is not online. Roblok1
Joined: 27 Jul 2011
Total Posts: 2019
01 May 2016 03:18 AM
b3


Report Abuse
Jammer622 is not online. Jammer622
Joined: 19 Nov 2008
Total Posts: 1739
01 May 2016 03:29 AM
ugh Just use a while true do loop. Something like this doesn't need so many bumps ;_;
Report Abuse
Roblok1 is not online. Roblok1
Joined: 27 Jul 2011
Total Posts: 2019
02 May 2016 12:37 PM
i just want the best way that doesn't cause that much lag.


Report Abuse
Roblok1 is not online. Roblok1
Joined: 27 Jul 2011
Total Posts: 2019
02 May 2016 01:00 PM
also, what script causes less lag? meaning, should i use a script or local script to run infinite loops?


Report Abuse
Jammer622 is not online. Jammer622
Joined: 19 Nov 2008
Total Posts: 1739
02 May 2016 11:31 PM
Depends on your definition of lag...

Scripts run on the server. Using them means using the server's power, which may result in slower internet connections between the server and its players.

Localscripts run on the client. Using them means using the client's power, which may result in frame skipping or slower internet connection between the server and that player alone.

And the best looping method I can think of would be a while [x] do loop whereas x is a boolean that is turned on or off depending on whether the sound is being used. For example:

Active = false
function Used()
if not Active then
Active = true
while Active and wait() do
--
end
end
end

When a script begins to move the brick, activate the function and the loop will run. When the brick is no longer being moved, you can set active back to false and it will stop taking up processing power. You can also set it to auto-disable if certain conditions are met.
It's not like Roblox servers run on a toaster anyways. Reducing server lag is sometimes just a matter of reducing how often your scripts are being used.
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
02 May 2016 11:36 PM
You would want to handle this client sided and probably use magnitude to find the distance between the car and the player then adjust the pitch accordingly


Report Abuse
Inigo18 is not online. Inigo18
Joined: 02 Feb 2014
Total Posts: 1041
03 May 2016 01:05 AM
What, no. Just put if statements according to the sit's speed.
Report Abuse
Roblok1 is not online. Roblok1
Joined: 27 Jul 2011
Total Posts: 2019
03 May 2016 02:04 PM
so, what I'm understanding is... I shold run the loop based on a condition. and I should run the loop on the client if it's too much for the server to handle.
Report Abuse
fearlesswee is not online. fearlesswee
Joined: 04 Sep 2010
Total Posts: 254
03 May 2016 02:48 PM
Script-

while true do
local Sound = script.Parent.SOUND NAME HERE
Sound.Pitch = script.Parent.Velocity.Magnitude
wait()
end

Place this in the brick with the sound. Very basic, but should do the trick.
Report Abuse
Inigo18 is not online. Inigo18
Joined: 02 Feb 2014
Total Posts: 1041
03 May 2016 04:27 PM
^ He's correct
Report Abuse
Roblok1 is not online. Roblok1
Joined: 27 Jul 2011
Total Posts: 2019
03 May 2016 11:57 PM
^ actually the script he posted is wrong.


Report Abuse
Jammer622 is not online. Jammer622
Joined: 19 Nov 2008
Total Posts: 1739
04 May 2016 12:03 AM
^ actually the script he posted would work fine

it's on a while true do loop, so it's infinite
it gets the sound from the same part that the script is in, assuming you changed 'sound name here' to the name of the sound.
it changes the pitch to a number value based on the velocity of the moving object. you could literally add a basic math function to tune it to your liking
there's a wait() so it doesn't eat up every bit of memory you have
there's an end so it's a proper script

but yeah, it didn't answer the best way to do it.
just settle for a conditional loop. as i said before, it's not like roblox's servers are made of freaking toasters. that and a part.changed event will eat up a ton more data than you want it to.
Report Abuse
Inigo18 is not online. Inigo18
Joined: 02 Feb 2014
Total Posts: 1041
04 May 2016 12:52 AM
Maybe you should review what Magnitude is. Also don't say something's wrong without telling us the output
Report Abuse
Roblok1 is not online. Roblok1
Joined: 27 Jul 2011
Total Posts: 2019
04 May 2016 02:11 PM
would you have to divide the magnitude of the part by what you want the max pitch you want to go at? because if the magnitude of the part was 50, the pitch would be 50. the sound would sound like screaming if the pitch was that high.


Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
04 May 2016 02:14 PM
Actually he was indeed wrong. We are looking for Doppler Effect, so it would be local.
Also, Roblox already simulates the Doppler Effect, so this is unnecessary.
Report Abuse
Hydrolock is not online. Hydrolock
Joined: 31 Mar 2010
Total Posts: 156
04 May 2016 02:15 PM
while wait() do
[sound].Pitch = ([block].Velocity.Magnitude/{yourspeed})+{idle pitch}
end

Replace {} (REMOVE THE BRACKETS) with numbers, replace yourspeed with your car's top speed
Replace [] (REMOVE THE BRACKETS) with the object


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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