I’m working on a project where I’m syncing lights with music but I’ve come up with an obstace as I want the music to be synced with each client I’m using a ServerScript to play the music but I’m using a LocalScript for the light syncing for performance reasons, However if I try get the PlaybackLoudness (or any property for that matter) of the Sound Instance I just get 0.
So my question is how would I get the property of a server playing sound from a LocalScript.
In the serverscript, you can use a separate connection for firing the PlaybackLoudness to the clients only when that value changes, rather than every frame in RenderStepped. Maybe also set up a variable for checking whether the volume has reached a certain goal so it doesn’t just fire during a tween or something. Or ask the clients to tween the volume themselves
local currentVolumeGoal
sound.Changed:Connect(function(property)
if property ~= "PlaybackLoudness" then return end
if sound.PlaybackLoudness ~= currentVolumeGoal then return end
VolumeChangeEvent:FireAllClients(sound.PlaybackLoudness)
end)
-- (Server)
local soundStartTime
function StartSound()
soundStartTime = os.time()
remoteEvent:FireAllClients(0)
end
function StartPlayerSound(player) -- If you want to play and synchronize to a new player.
local currentTime = os.time() - soundStartTime
remoteEvent:FireClient(player, currentTime)
end
-- (Client)
remoteEvent.OnClientEvent:Connect(function(position)
sound:Play()
sound.TimePosition = position
end)