So I’m trying to have this bar that represents the playbackloudness of a looped playing audio, but it only works when I’m running it, not playing it. If I go on serverside, the playbackloudness is 0 even when it’s playing and loud and clear, but if i run the game the playbackloudness isn’t 0.
Where are you reading PlaybackLoudness off of? If I remember correctly, the server doesn’t receive an accurate value for PlaybackLoudness or one at all because it doesn’t play audio in the first place, it just replicates playback. Using PlaybackLoudness from the client generates the best results.
The properties tab. Server script also reads it. Inspect video closely.
This thread confuses me. What are you referring to when you say “running” and “playing”? Between a live server and a play solo session, or the server and client view, or what? I don’t understand.
Read my comment again as well. The client has a better hold on reading an accurate value for PlaybackLoudness than the server. The server doesn’t play sounds, clients do. The server doesn’t hear anything, that’s your machine playing off audio.
By playing I’m referring to the play function in test tab of ROBLOX studio.
By running I’m referring to the run function of the test tab of ROBLOX studio.
The sound is set to playing and looped in studio. When I run it, the audio plays and shows playbackloudness when looking at properties, and the script is able to see it as well. When I play it, the audio plays but the playbackloudness is always zero when looking at the properties. Both client and server view sees the playbackloudness as zero.
Could you try printing out the value from the command bar or the script in a Studio play session if the value is above 0 and see if it ends up ever being a non-zero value? Confer with the PlaybackLoudness documentation. Due to constant fluctuation and for performance reasons, the properties window can see it as 0 but scripts will see the proper value.
Playbackloudness can only be read from the Client. Make sure that the script that you have it in is inside a LocalScript and not a Serverscript.
Please inspect the video closely. It clearly shows the script AND properties seeing the playbackloudness as 0, but when running the script AND properties sees it as what it’s supposed to be.
:?
I don’t understand why you keep volleying me back to the video. I’ve inspected the video many times and I’m using my personal experience with PlaybackLoudness to reply. What are you trying to highlight to me? Have you looked at my responses and tried putting any of them to practice yet? Doesn’t seem so. More than anything, you’re using PlaybackLoudness wrongly.
I’m going to reiterate my points again in case you missed them:
-
The server does not receive a non-zero value for PlaybackLoudness because the server doesn’t play audio, your machine (and therefore the client) does. You aren’t supposed to read PlaybackLoudness from the server.
-
Use PlaybackLoudness from the client for the best results. This will make working with PlaybackLoudness smooth, accurate and devoid of any issues. I’ve made visualisers for a dance floor using PlaybackLoudness before. It worked from the client, not the server.
Besides: why are you trying to force it to work in all modes of testing in the first place? Why do you need both forms of testing? If it works in a production server and you’re able to test it via Play which simulates a live environment, that’s fine. It seems like you’re propagating an unnecessary worry here.
I went ahead and created a repro so I could inspect the situation because I frankly don’t understand what the problem is here or if any of what I’m saying is actually being read.
PlaybackLoudness ReadFromServer.rbxl (20.8 KB)
Test Mode | View | PlaybackLoudness Value (property) | PlaybackLoudness Value (Gui) |
---|---|---|---|
Run | Server | Non-zero | ← |
Play | Server | Zero | ← |
Play | Client | Non-zero | Zero (due to server) |
PlaybackLoudness ReadFromClient.rbxl (20.8 KB)
Test Mode | View | PlaybackLoudness Value (property) | PlaybackLoudness Value (Gui) |
---|---|---|---|
Run | Server | Undefined | Not set by server |
Play | Server | Undefined | Not set by server |
Play | Client | Non-zero | Non-zero |
PlaybackLoudness is behaving as expected in all forms of testing except Run. I don’t know what’s with Run, but it’s a pointless testing mode (to me at least) and you should stop worrying so deeply about it. Read it from the client and use Play. Stop worrying about its behaviour in Run and fix your implementation.
The server does not have an audio device, it will see PlaybackLoudness as zero. Naturally if it’s updating the Gui, that means the client will also not see any change to the Gui. Play simulates proper behaviour for live games.