I want to make car sounds. You know, so as speed increases, playback speed increases.
How do I make PlaybackSpeed linear to Speed?
2 answers
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
13 comments
What should I change it to
@TheBeaver101 the sound instance
Forgive me, but like... what exactly is a sound instance? I know you're laughing at me right now but I literally just started with studio and scripting.
@TheBeaver101 the thing that plays sound
Oh lol ok thanks. So if it's in a part then just put the part name.
@TheBeaver101 well it cant be a part instance because it needs to be a sound instance
So the sound instance is basically the thing called "Sound" you put in to a part, union, whatever. So if it was named "sound" I'd just put "sound" right?
@TheBeaver101 yea like script.Parent or workspace.Sound just get to sound
@DanzLua do I need to add anything to the vehicle seat that I am putting this script in besides the sound?
Does not work. On the 5th line "Sound" has a blue line under it. "W001 Unknown Global 'Sound'" it says.
@TheBeaver101 on line 5 change Sound to sound
It doesn't work :/ Is there something else I need to add to the vehicle seat? The name is Vehicle Seat for the seat, and I have nothing in there besides the script and the sound and some welds.
@TheBeaver101 If you don't understand what I'm saying I suggest you read up on basic scripting before you use this site
Perhaps have a value for the speed of the car, and the max speed of the car..
You can change the volume then using a Changed event on the carSpeed, and the formula: Volume = CarSpeed/MaxCarSpeed
local carSpeed = script.Parent:WaitForChild("carSpeed") --speed val
local maxSpeed = script.Parent:WaitForChild("maxSpeed") --maxspeed val
local volume = script.Parent:WaitForChild("Volume") --volume val
carSpeed.Changed:Connect(function(new) --Changed event on speed val
volume.Value = new/maxSpeed.Value --formula
end)
4 comments
Wait... so what should the whole script look like? I'm starting out and I know nothing about scripting. Should I add some NumberValues too?
That's what the whole script should look like. vals should be actual IntValue/NumberValue objects, yes.
Should I have the Values in Configurations?
-_-
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Normalize the car's speed (i.e. make it a value between 0 and 1, possibly by dividing it by the car's max speed) and set it as the sound's volume/speed.
Why did somebody down vote this? What the hell did I do wrong?