As you can see from the title and the issue’s with the script and from the notes there’s alot of issues with it.
local cars = script.Parent.Car.Value -- Replace with the appropriate car reference
local carSeat = cars.DriveSeat
local wheelParts = {} -- Stores references to the car's wheel parts
local brickColor = BrickColor.new("Brick yellow") -- Replace with the desired brick color
local soundInstance = script.OverpassColorEffect
-- issue with the script
-- seems to keep bugging in and out when it's collideded with the solid lines and dashed texture line
-- tried to fix it but it's giving more problems
local debounce = false
local function playSoundEffect(speed)
local minSpeed = 0
local maxSpeed = 100
local minPitch = 0
local maxPitch = 2.5
local createdPitch = ((speed - minSpeed) / (maxSpeed - minSpeed)) * (maxPitch - minPitch) + minPitch
if createdPitch > maxPitch then
soundInstance.Pitch = 2.5
else
soundInstance.Pitch = createdPitch
end
if soundInstance.IsPlaying then
-- To try to see if this works
warn("The sound is currently playing, please wait for the client to get off the overpass bridge.")
-- it spams it.. weird
else
warn("Played")
if debounce == true then
soundInstance:Play()
debounce = false
else
return warn("The sound is currently playing, please wait for the client to get off the overpass bridge.")
end
end
end
-- Function to set up wheel collisions for the car
local function setupWheelCollisions()
local wheels = cars.Wheels
for _, wheel in pairs(wheels:GetChildren()) do
if wheel:IsA("Part") then
print(wheel)
table.insert(wheelParts, wheel)
end
end
for _, wheelPart in pairs(wheelParts) do
wheelPart.Touched:Connect(function(part)
-- Fixed the change of lanes issue, siked back on me
if part.BrickColor == brickColor or part.Transparency == 1 then
-- created a new issue for non overpass colors
if part.BrickColor == brickColor then
local speed = carSeat.Velocity.Magnitude
playSoundEffect(speed)
debounce = true
end
elseif part.BrickColor ~= brickColor then
soundInstance:Stop()
debounce = true
end
end)
end
end
setupWheelCollisions()
It’s also the annoying fact that it keeps spamming the console (i tried debounce) and the sound keeps bugging in and out, and that the pitch wont smoothing transition (I’m going to try TweenServiceSpam).
But my intentions for it to be like @TwentyTwoPilots’s method of road sound effect. But not exactly like his because I have more for certain road colors.