I am making a themepark game, and my Roller Coasters need to make sound, so how could I add a script(s) that change an audio’s pitch according to the speed of the roller coaster train?
I have seen something like it in Starmarine614’s Roblox Point game, and I think Universal Roblox Themepark but I cant seem to come up with a way of doing it myself
Hello, try this script, make sure to change Part, and Sound to the rollercoaster and sound in your game ‘’'local train = game.Workspace.Part
local sound = game.Workspace.Sound
sound.PlaybackSpeed = 1
game:GetService(“RunService”).RenderStepped:Connect(function()
local speed = train.Velocity.Magnitude
local targetPitch = math.clamp(speed / 100, 0, 2)
local rate = 0.1
sound.PlaybackSpeed = sound.PlaybackSpeed + (targetPitch - sound.PlaybackSpeed) * rate
end)‘’’
1 Like
I think I made a mistake, the roller coasters I am using are not actually moving, they use a CFrame system.
So is there any way of having a script, like this work for anchored or “not moving” objects maybe depending on their position?