You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I want a sound to be played whenever a player hits someone locally(for lag reasons), but I also want the sound to be played for other player once the server register the hit.
- What is the issue? Include screenshots / videos if possible!
I noticed that when the server plays the sound the player who called the server will hear the sound twice. Once from itself and the other from the server.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have found a solution but I dont think this will be efficient enough(It involves using FireAllClients)
Some part of Server script fires all clients
local RS = game:GetService("ReplicatedStorage")
local DA = RS:WaitForChild("DogAttack")
DA:FireAllClients(Player,AttackSwitch,BiteSwitch,victim)
Local script from StarterPlayerScript recives the Call
local RS = game:GetService("ReplicatedStorage")
local DA = RS:WaitForChild("DogAttack")
local Player = game.Players.LocalPlayer
DA.OnClientEvent:Connect(function(Attacker,AttackVal,BiteVal,Victim)
if Player ~= Attacker then
-- Insert sound using victim
end
end)
I want to know if there are any better solutions to this.