Sound pitch when accelerating doenst work

Hello there,
havent posted in a while, but yeah.

I am making a tank script, and when it accelerates the playback speed changes. But it prints out nothing, even printing “changed” doesnt work.

It always says a error so i made it that the speed is a value,

this is the one for the speed value.

local spd = script.Parent.Parent.Parent.Base.Velocity.Magnitude

while true do
	wait(0.1)
	script.Parent.Value = spd
end

This seems to be working, but this is the localscript under the sound.

local spd = script.Parent.Parent.Speed

spd.Changed:Connect(function(spdd)
	local spddd = tonumber(spdd)
	local spdddd = spddd / 48
	print("changed")
	script.Parent.Parent.IDLE_SFX_TANK.PlaybackSpeed = spdddd
	script.Parent.Parent.IDLE_SFX_TANK:Pause()
	wait(0.1)
	script.Parent.Parent.IDLE_SFX_TANK:Play()
end)

btw it doenst matter if it is played or not it still doenst work

These are the locations.
Screenshot_87

Can someone help, thanks!
Nice day!

1 Like

Local scripts can’t run in workspace, are you sure the first script is working?

You can try moving the second localscript into starter player scripts and see if that changes anything.

tried that, doenst work sadly

I’d transition this over to a regular Script.

local basePlayback = 0.6

game:GetService("RunService").Heartbeat:Connect(function()
	local velocity = seat.AssemblyLinearVelocity.Magnitude
	seat.Engine.PlaybackSpeed = (velocity / seat.MaxSpeed) + basePlayback
end)

Taken from some old vehicle code of mine, so I’m not sure how practical the use of RunService is.
You’ll have to change the variables accordingly, and you can also tweak the basePlayback variable to set the base speed the audio will play at.

Thank you, this really helped!

1 Like

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