print what exactly? like just print the ‘print(song.blahblah’ and ‘print(alpha)’ or the entire thing
Where are the sound instances located? Go pathfind to those music and then print its PlaybackLoudness
print(workspace.blahblah.blahblah.blahblah.music1.PlaybackLoudness)
print it repeatedly while the song is playing and you can hear it
So then why does the script print zeros??? Can you go double-check to see if the song placed in _G is actually the one that’s playing?
local song = sounds[math.random(1, #sounds)]
song:Play()
_G.PlayingSong = song
end
playRandomSong()
well heres my function, it looks like it should work properly, i personally dont see what would be wrong
Ok plan B: go learn how to use remote events and move the color changing script to the client
i actually do remember how to use remote events, let me mess around with it and ill come back. where do i put the local script for color change?
Do note that you’ll probably need two separate remotes; A remote function for requesting the currently playing song when the player joins the game, and a remote event for when the server changes the song
serverscript:
local song = sounds[math.random(1, #sounds)]
song:Play()
_G.PlayingSong = song
remote:FireClient()
end
playRandomSong()
localscript:
Remote.OnClientEvent:Connect(function(player)
res.Heartbeat:Connect(function()
local song = _G.PlayingSong
if song and song.IsPlaying then
local alpha = song.PlaybackLoudness * .01
print(song.PlaybackLoudness)
print(alpha)
part.Color = clr_black:Lerp(setColor, alpha)
end
end)
end)
alright so i added the remotes (tell me if they look wrong) but what should i change with the _G stuff to make it fit this?
Don’t use _G anymore
And I think you did everything wrong
It should be something like:
--server
function playRandomSong()
local song = sounds[math.random(#sounds)]
song:Play()
remote:FireAllClients(song) --tell all of the clients which song is playing
end
--client
local playingSong
remote.OnClientEvent:Connect(function(newSong)
playingSong = newSong
end)
res.RenderStepped:Connect(function()
if playingSong and playingSong.IsPlaying then
local alpha = math.clamp(playingSong.PlaybackLoudness * .01, 0, 1)
part.Color = clr_black:Lerp(setColor, alpha)
end
end)
‘song’ is a global unknown, what was it replaced with?
oops minor spelling mistake
its replaced with playingSong
(like it wasn’t obvious enough in that example code)
okay i fixed everything here are my scripts:
local part = workspace:WaitForChild('TRIAGE')
local setColor = Color3.fromRGB(75, 43, 255)
local clr_black = Color3.new()
local La = game.ReplicatedStorage.Layla
local playingSong
La.OnClientEvent:Connect(function(newSong)
playingSong = newSong
end)
res.RenderStepped:Connect(function()
if playingSong and playingSong.IsPlaying then
local alpha = math.clamp(playingSong.PlaybackLoudness * .01, 0, 1)
print(playingSong.PlaybackLoudness)
print(alpha)
part.Color = clr_black:Lerp(setColor, alpha)
end
end)
local baba = MUSIC:GetChildren()
local layla = game.ReplicatedStorage.Layla
local repStorage = game:GetService("ReplicatedStorage")
local remote = repStorage:WaitForChild("Layla")
local sounds = {
MUSIC:WaitForChild("DiamondAndPearl"),
MUSIC:WaitForChild("AdoreYouHarryStyles")
}
function playRandomSong()
local song = sounds[math.random(1, #sounds)]
song:Play()
remote:FireAllClients(song)
end
playRandomSong()
so did it work?
( 20 charsss )
uhh it doesnt 88382838823432534534
I did say something about using two remotes
It’s so that when the player joins after the song had already started playing the player can still know what song is currently playing
In this case, you can make your remote event dual purpose:
--serverscript
local song --tada it's now outside
function playRandomSong()
song = sounds[math.random(1, #sounds)]
song:Play()
remote:FireAllClients(song)
end
remote.OnServerEvent:Connect(function(player) --when a client asks what song is playing, just tell them
return song
end)
playRandomSong()
--localscript
local playingSong = La:FireServer() --tada instead of nil its going to ask the server for the song
La.OnClientEvent:Connect(function(newSong)
playingSong = newSong
end)
okay i implemented the new stuff so that it has the dual purpose but it still does not function. idk if i mentioned this before but it used to be black when playing because of the clr_black thing but now it remains the color that it is in workspace
try printing out the things again
i kept the
print(playingSong.PlaybackLoudness)
print(alpha)
inside of the script and it hasn’t printed since ive been testing the new stuff