Hi there, I am trying to pass a value from the client to the server using remote events. The issue is, is that I am receiving an error saying the remote event invocation queue was exhausted for replicatedstorage. I do not know what the error mean, nor how to fix it with possible solutions.
local script
local Sound = workspace.Sound
local remote = game.ReplicatedStorage.PlaybackLoudness
game:GetService('RunService').Heartbeat:Connect(function(deltaTime)
local pl = Sound.PlaybackLoudness
remote:FireServer(pl)
end)
RunService.HeartBeat runs every frame. So basically you are firing a remote event ~60 times per second, which of course cant be done, and even if can, it will be extremely heavy on performance (your game will be laggy as hell)
There is a .Changed event that fires every time the value changes. You can put your remote event in there, because there is no reason to pass the value if it is the same
I checked there, but I’m still confused. Would I do it like this?
local Sound = workspace.Sound
local remote = game.ReplicatedStorage.PlaybackLoudness
local pl = Sound.PlaybackLoudness
pl.Changed:Connect(function(value)
remote:FireServer(value)
end)
What’s happening is that you’re creating more and more connections with every 1/60th of a second (this will absolutely tank performance and destroy your game very quickly) — you need to firstly remove the Heartbeat connection from your server script and leave the OnServerEvent by itself.
You don’t need to change the LocalScript — just be mindful of the value that the client passes to the server (clamp the value passed to the server to 0, 1000); exploiters can very easily spoof the values that are passed to the server.
So is this what I would do, because it’s still throwing me the same error.
ls
local Sound = workspace.Sound
local remote = game.ReplicatedStorage.PlaybackLoudness
game:GetService('RunService').Heartbeat:Connect(function(deltaTime)
local pl = math.clamp(Sound.PlaybackLoudness,0,1000)
remote:FireServer(pl)
end)
ss
local remote = game.ReplicatedStorage.PlaybackLoudness
remote.OnServerEvent:Connect(function(player,pl)
print(pl)
end)
This doesn’t work because you are indexing .Changed from the Number Sound.PlaybackLoudness. Sound.PlaybackLoudness is a number, and therefore does not have any events or functions. The property is not an object itself – it’s just the raw type. What you want to do is get the PropertyChangedSignal of PlaybackLoudness by calling :GetPropertyChangedSignal on the sound and passing a String value "PlaybackLoudness", and then connect that signal. That would look like the following:
local Sound = workspace.Sound
local remote = game.ReplicatedStorage.PlaybackLoudness
Sound:GetPropertyChangedSignal("PlaybackLoudness"):Connect(function()
remote:FireServer(sound.PlaybackLoudness)
end)
As a side note, are you sure you have your server script in a container that can run it (such as ServerScriptService)?
Your current implementation is not ideal; animations of characters should be played on the Client, meaning there really should be no involvement with the server when adjusting the speeds. Can I see the script you are using to play these animations?