I need sound for my roller coaster, and I want it to change in pitch depending on how fast the roller coaster train is moving.
So faster = Higher pitch
slower = lower pitch
not moving = 0 pitch.
Assuming you’re keeping track of the speed of the coaster itself, just set the pitch to its speed scaled by some constant.
pitch = speed * dampening_factor
This way, the pitch is 0 when speed is 0, 1 when speed * dampening_factor is 1, and higher/lower otherwise.
You can also use math.clamp
to clamp the pitch between two values, and you can use different methods/formulas to scale the pitch based on how you want the pitch to change.
Also, keep in mind that ROBLOX sounds come with a pre-built doppler effect that you can modify in SoundService
. If the roller coaster is being moved physically, then the audio’s pitch will change as it passes bystanders.