Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make it so that as the speed of a car increases, the pitch of a sound increases?

Asked by 7 years ago

I want to make it so that as the speed of a car increases, the pitch of a sound that is in the vehicle seat also increases. Here is the current function that I have:

local maxSpeed = filtered local minPitch = filtered local maxPitch = filtered local pInc = (maxPitch / maxSpeed)

local function setPitch(speed) local currPitch = (speed * pInc) currPitch = math.clamp(currPitch, minPitch, maxPitch) sound.PlaybackSpeed = currentPitch end

What do I need to do to make it work? I have it in my vehicle seat with a sound that is not playing. Please help, I have been looking for months.

0
Pitch is deprecated, but you can achieve a similar effect by inserting a PitchShiftSoundEffect into the Sound Object randomsmileyface 375 — 7y
0
but TheBeaver101 28 — 7y
0
The point is to make it so as you accelerate the sound playing in the vehicle seat gets a higher pitch, or in this case now, higher playback speed. So speed is linear to playback speed basically is what I want, similar to the cars in jailbreak or prison life. TheBeaver101 28 — 7y

2 answers

Log in to vote
0
Answered by
thesit123 509 Moderation Voter
7 years ago

The property, Pitch, is deprecated: Link to Roblox Wiki

0
Alright but like what else should I do to the script, like how should it look. TheBeaver101 28 — 7y
0
Try Playbackspeed. thesit123 509 — 7y
0
I did :c TheBeaver101 28 — 7y
Ad
Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
7 years ago

We are going to change the pitch of our sound change depending on the velocity of the Seat

We will create a while loop that will take the velocity of the seat and get a speed out of it, then we will do some math to get the pitch we want to set the sound to

local seat = script.Parent.MainSeat
local sound = script.Parent --Change this
while true do
    speed = math.floor(math.sqrt((seat.Velocity.X^2)+(seat.Velocity.Y^2)+(seat.Velocity.Z^2)))
    Sound.Pitch = (speed/150)+1
    wait(.5)
end
0
What should I put for the second line? TheBeaver101 28 — 7y
0
It does not work :C TheBeaver101 28 — 7y
0
@TheBeaver101 the sound ;-; DanzLua 2879 — 7y
0
Wait so the id? TheBeaver101 28 — 7y
View all comments (3 more)
0
@TheBeaver101 no the sound instance ;-; DanzLua 2879 — 7y
0
wait so what should it loo like TheBeaver101 28 — 7y
0
change the Sound.Pitch to Sound.PlaybackSpeed ChristianTRPOC 64 — 4y

Answer this question