Whats the easiest way to dampen a number with a changing target value?

What im trying to do is, to dampen or smooth out a number going up or down in rough steps

You can hear the trucks sound going up and down roughly when shifts to the next gear and I want it to do so smoothly as if it has inertia

Should i try to use a graph/table sort of deal and multiply the pitch based on the corresponding speed and table value?

I have to say that im quite a noob at scripting and that Ive only made scripts for making hingemotors and servos move before

I havent found anything which i can use on the internet, because all of those number damping scripts can only have fixed targets or starting values so this seems like a difficult problem to solve

Please respond, many thanks

I don’t know how you have the script set up but you can try adding wait() in it to delay it a bit.

1 Like

Heres a screenshot of it, sorry I forgot to include that

You could try interpolating the sound pitch maybe

2 Likes

I think im just going to try to cover it up by playing a sound each time it “shifts” although im even having trouble with that, as any call to my function isnt connecting or making the sound play

image

I dont understand why this simple addition to the script isnt working its been an hour please help
The sound is able to play if you set it to playing at the start so I did set it up right and ive tried touched as a function call but then nothing happened either

I finally managed to get it working by putting the shifting noise code into its own script.

You’ve got an infinite loop right before you define ShiftSound and connect it to the property change signal.

print("A")
while wait() do end
print("B")

would only print “A” and never get to “B” because there’s an infinite loop right before it. This also explains why moving that code into a separate script fixed it.

1 Like

Sound instances don’t replicate across the server-client boundary for the most part, so be wary of that.

1 Like

Huh I didnt know loops cut things off like that…
Thank you, very helpful!!