How would i set my Image Transparency based on the static sound?, But that the transparency cannot go up more than 1, since if the transparency is set to 1 it will no longer be possible to see
This is my current script : (everything is running inside a RenderStepped Function)
if closestPart then
print("He is here")
if not static1.IsPlaying then
static1:Play()
static2:Play()
if static1.PlaybackLoudness <= MaxPlaybackLoudness then
image.ImageTransparency = "0"..static1.PlaybackLoudness
end
end
if closestPart then
print("He is here")
if not static1.IsPlaying then
static1:Play()
static2:Play()
if static1.PlaybackLoudness <= MaxPlaybackLoudness then
image.ImageTransparency = 0 ..static1.PlaybackLoudness
end
end
Use math.clamp(), you will likely need to change “100” to a value suitable to the audio, you want to divide it by double its average “PlaybackLoudness”. Such that the value returned by the division is 0.5 on average.
math.clamp() will use the value of the division if it lies between the two clamped values otherwise one of the clamped values is used instead.