function module:ServerToClientManageSound(PlayerAlvo:Player, AudioPlayer:AudioPlayer)
if PlayerAlvo ~= nil then
print("Function module:ServerToClientManageSound")
ClientAudioPlayerSend:FireClient(PlayerAlvo, AudioPlayer)
print("DEBUG 1")
if PlayerAlvo.Character.Som:GetAttribute("GerenciarVolumeLoop") == false then
PlayerAlvo.Character.Som:SetAttribute("GerenciarVolumeLoop", true)
end
end
end
Client:
local RS = game:GetService("ReplicatedStorage")
-- REMOTE EVENTS //
local ClientAudioPlayerSend = RS.Functions.Som:WaitForChild("ClientAudioPlayer")
ClientAudioPlayerSend.OnClientEvent:Connect(function(AudioPlayerRecebido:AudioPlayer )
print("ClientAudioPlayerSend Client Recebeu event! AudioPlayer Parent:"..AudioPlayerRecebido.Parent.Name)
if AudioPlayerRecebido ~= nil then
if not table.find(AudioPlayers, AudioPlayerRecebido) then
print("CLIENT: DEBUG 1")
table.insert(AudioPlayers, AudioPlayerRecebido)
end
end
print("CLIENT: DEBUG 2")
end)
Hello!
Are you sure that the client script does not have a second identical instance that can listen to this remote? If this is fine, analyze the calls of your module:ServerToClientManageSound function. Let me know if you have any more information on this!
I don’t know the structure of your system, but I can assume that there is a problem with calling that function.
You can fix it by adding a true/false toggle to your script. Like so:
local CanManageSound = true
function module:ServerToClientManageSound(PlayerAlvo:Player, AudioPlayer:AudioPlayer)
if CanManageSound then
CanManageSound = false
if PlayerAlvo ~= nil then
print("Function module:ServerToClientManageSound")
ClientAudioPlayerSend:FireClient(PlayerAlvo, AudioPlayer)
print("DEBUG 1")
if PlayerAlvo.Character.Som:GetAttribute("GerenciarVolumeLoop") == false then
PlayerAlvo.Character.Som:SetAttribute("GerenciarVolumeLoop", true)
end
end
task.wait()
CanManageSound = true
end
end
This Local Script is inside StarterPlayerCharacter. There is a possibility that the game is creating 2 characters and then having this script 2 times ?
I found that my script clones my character when i enter the game. I think that is duplicating script. I changed to PlayerScripts instead CharacterScripts and solved the issue