How to make a sound volume goes up when a BasePart moves?

You can write your topic however you want, but you need to answer these questions:

  1. I wanna know how to make a sound volume goes up when a BasePart moves?

  2. I don’t know how. When i try using For loops comparing value thing (or whatever they call it), it just gives out an error

  3. I’ve tried using Velocity with For Loops comparing value thingy, But yeah it doesn’t work (The code shown below)

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

while wait() do
	if script.Parent.Velocity >= Vector3.new(1, 0, 1) then
		script.Parent.Roll.Volume = script.Parent.Velocity / 1
	end
end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

I did this for a boat script of mine!

Swap 1.5 for the loudest you want it to get.

while true do task.wait()
	Sound.Volume = math.min(1.5, (Seat.Velocity.Magnitude/15)*1.5)
end
local part = script.Parent

part:GetPropertyChangedSignal("Velocity"):Connect(function()
	if part.Velocity.X > 1 or part.Velocity.Z > 1 then
		if part.Velocity.X > part.Velocity.Z then
			part:WaitForChild("Roll").Volume = part.Velocity.X
		elseif part.Velocity.Z > part.Velocity.X then
			part:WaitForChild("Roll").Volume = part.Velocity.Z
		end
	end
end)

This worked to play the sound but when it stops moving it still plays sooo

local part = script.Parent

part:GetPropertyChangedSignal("Velocity"):Connect(function()
	if part.Velocity.X > 1 or part.Velocity.Z > 1 then
		if part.Velocity.X > part.Velocity.Z then
			part:WaitForChild("Roll").Volume = part.Velocity.X
		elseif part.Velocity.Z > part.Velocity.X then
			part:WaitForChild("Roll").Volume = part.Velocity.Z
		end
	else
		part:WaitForChild("Roll").Volume = 0
	end
end)

I didn’t know you wanted that behavior.

Yeah i did that

forgot to give solution on your last answer tho