hey! im trying to create something like the video above. (cant hear audio with gyazo gif but its using playbackloudness to match with the audio.)
i have a script that does this but with the height/width of the object, how would i do it with color? the script has a color part, but it doesnt use renderstepped so its either one color or the other. tell me if u wanna see the script and ill reply w it
That’s a neon material and the “bloom” effect depends on the brightness/value of the color which you can interpolate
Note that in interpolation, the alpha value needs to be normalized into the interval [0, 1]
You could:
Interpolate between the set color and black
--init
local setColor = Color3.fromRGB(100, 200, 255) --example
local clr_black = Color3.new()
--inside renderstepped
local alpha = .5 --0 is minimum volume, 1 is max
local color = clr_black:Lerp(setColor, alpha)
Use the HSV constructor
--init
local setColor = {.25, 1} --hue and saturation respectively
--inside renderstepped
local alpha = .5 --0 is minimum volume, 1 is max
local color = Color3.fromHSV(unpack(setColor), alpha)
You define the part somewhere and just change the color
Example:
local part = workspace:WaitForChild('Sign')
part.Color = ...--something
“init” means initialization, it’s just there to tell you that that portion of the script should be outside and at the top of the script (it initializes the rest of the script)
ohh okay makes sense, while i try to mess with this script i have a quick semi-related question that you may or may not be able to answer. is there any way to identify in a variable the current playing sound? for example, i have the line below which just identifies one sound but i want to make it so that it identifies the current playing song which is randomized through a table in another script.
local loudness = game.Workspace.Sound.PlaybackLoudness
You could alternatively use the global table _G instead of bindable events if you think that’s simpler. It’s a table that is shared by all scripts in the same execution level, meaning that its internals can be accessed and modified by multiple scripts
In the song rotation script, you can toss the playing sound instance into _G:
--just an example
function playRandomSong()
local song = sounds[math.random(#sounds)]
song:Play()
_G.PlayingSong = song --put the song in the _G table
end
And in the color-changing script, you will use that song accordingly:
--just an example
local res = game:GetService('RunService')
local part = workspace:WaitForChild('something')
local setColor = Color3.fromRGB()
local clr_black = Color3.new() --empty constructor means black
res.RenderStepped:Connect(function()
local song = _G.PlayingSong
if song and song.IsPlaying then --make sure there's actually a song playing first
local alpha = song.PlaybackLoudness * .001 --divide by 1000 to normalize the number since PlaybackLoudness is a number ranging from 0 to 1000
part.Color = clr_black:Lerp(setColor, alpha)
end
end)
Note that _G does not replicate between clients and the server
yes, but do note that RenderStepped doesn’t exist on the server and you will have to change it to either .Stepped or .Heartbeat
Ideally, for optimization reasons, you should be changing the part’s color on the client as doing it on the server might overload the replication system and make your game laggy
So sometime in the future when you do learn how to use remote events, you should swap it over, but for now it should work fine
alright! changed it to heartbeat. i added the _G thing into my music script and now the music isnt playing at all, let alone being randomized. did i do something wrong?
local baba = MUSIC:GetChildren()
local layla = game.ReplicatedStorage.Layla
local sounds = {
MUSIC:WaitForChild("DiamondAndPearl"),
MUSIC:WaitForChild("AdoreYouHarryStyles")
}
function playRandomSong()
local song = sounds[math.random(1, #sounds)]:Play()
_G.PlayingSong = song
end