Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does my audio now lag in-game, and not before?

Asked by
Nariox 0
5 years ago

So this script measures the pitch for the boats engine, and water sounds with the speed of the boat. Now this script doesn't work, and it the audio somewhat lags in-game even though it runs smoothly.
The script for it:

local Engine = script.Parent.Engine
local WaterEffects = script.Parent.WaterSounds

while true do
    speed = math.floor(math.sqrt((Engine.Velocity.x^2)+(Engine.Velocity.y^2)+(Engine.Velocity.z^2)))    
    Engine.EngineSounds.Pitch = (speed/150)+0.300
    WaterEffects.Water.Pitch = (speed/150)+0.500
    WaterEffects.Water.Volume = Engine.Velocity.Magnitude/170
    wait()
end

Should I be using remote events, or anything like it with replicated storage?

Answer this question