Sound speed changes depending on how fast an object is going

So, was making a mechanic for my game. But I needed some effect to it. Like a speed effect. But I didn’t know how to make it so that the pitch changes (on the title of this topic.) Any ideas are appreciated. Here’s the clip. It doesn’t look that realistic.

you can make ur speed of ur sound to the velocity of your vehicle seat part

sounds.PlayBackSpeed = Part.AssemblyLinearVelocity.Magnitude
1 Like

I didn’t hear anything. Also the script is a server script. Here’s part of the script.

	for waypoint = 1, #waypoints:GetChildren() do
		script.Parent.Sounds.Minecart.PlaybackSpeed = script.Parent.Sounds.AssemblyLinearVelocity.Magnitude
		local moveToWaypoint = tweenservice:Create(mover, tweeninfo, {CFrame = waypoints[waypoint].CFrame})
		moveToWaypoint:Play()
		moveToWaypoint.Completed:Wait()
	end

are you checking a parts velocity or a sounds velocity because a sound is not a part with velocity. and make it in a loop in a seperate script

1 Like

I’m checking a part’s velocity. I’m also using TweenService.

Since you’re using tweening, it’s harder to make the script but I’ve created something that should work

local Old = Vector3.one

local Part = script.Parent
local Sound = Part:WaitForChild("Engine")
local SpeedMultiplier = 2 -- if speed is too low, make higher, vice versa for speed too high
local StartingSpeed = 1

local function GetPosition()
	return Part.CFrame.Position
end

while true do
	local New = GetPosition()
	local Dif = ((Old-New).Magnitude*SpeedMultiplier)+StartingSpeed

	
	game:GetService("TweenService"):Create(Sound, TweenInfo.new(.1), {PlaybackSpeed = StartingSpeed+Dif}):Play()
	Old = New
	task.wait(.1)
end

make sure this is a seperate script, just replace the variables with your sounds / parts

1 Like

You can use Playbackspeed like precise suggests but I would also consider using ShiftPitchSoundEffect as well. It achieves a very similar effect but I think it might be worth considering for this use case. Playing something faster and changing the pitch are different things.

2 Likes

How can I make it so that when it reaches pitch 2, it doesn’t increase more than that?

1 Like

You can use math.clamp.

local Old = Vector3.one

local Part = script.Parent
local Sound = Part:WaitForChild("Engine")
local SpeedMultiplier = .5 -- if speed is too low, make higher, vice versa for speed too high
local StartingSpeed = 1

local function GetPosition()
	return Part.CFrame.Position
end

while true do
	local New = GetPosition()
	local Dif = math.clamp( ((Old-New).Magnitude*SpeedMultiplier)+StartingSpeed, 0, 2)

	
	game:GetService("TweenService"):Create(Sound, TweenInfo.new(.1), {PlaybackSpeed = StartingSpeed+Dif}):Play()
	Old = New
	task.wait(.1)
end

on the dif line, the “2” is the max pitch. You can change this if you wanted

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.