In the context of an music amplitude bar, how would I go about mapping my values that currently go from 0 to 1, into a different output range, say 5 to 10, or even 10 to 1. If this is possible let me know.
I have put the code below. Any advice is greatly appreciated!
--wait for Sound
local Sound = game.workspace:WaitForChild("Sound")
local Players = game:GetService("Players")
-- wait for local player PlayerGui
local LocalPlayer = Players.LocalPlayer
local playerGui = LocalPlayer:WaitForChild("PlayerGui")
-- create a ScreenGui
local screenGui = Instance.new("ScreenGui", playerGui)
-- create a holder for our bar
local frame = Instance.new("Frame", screenGui)
frame.AnchorPoint = Vector2.new(0.5,0.5)
frame.Position = UDim2.new(0.5, 0, 0.5, 0)
frame.Size = UDim2.new(1, 0, 0.05, 0)
-- create a bar
local bar = Instance.new("Frame", frame)
bar.Position = UDim2.new(0, 0, 0, 0)
bar.Size = UDim2.new(1, 0, 1, 0)
bar.BackgroundColor3 = Color3.new(0, 1, 0)
local Baseplate = workspace.Baseplate
-- define a max loudness
local maxLoudness = 1000
-- animate the amplitude bar
while true do
local amplitude = math.clamp(Sound.PlaybackLoudness / maxLoudness, 0, 1)
bar.Size = UDim2.new(amplitude, 0, 1, 0)
bar.BackgroundColor3= Color3.new(amplitude, 0 , 0.1)
Baseplate.Transparency = amplitude
print(amplitude)
wait()
end

2 comments
Looks promising! if this works I will accept your answer.
your method works, but I have found a universal formula for this answer.