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.
The property, Pitch, is deprecated: Link to Roblox Wiki
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