How would I make a remote event affect only the person who fired it?

Guns in my game have their reload script in a local script, so if I try to play sounds from it, they will only play for the person who reloaded instead of anyone who is near that person.

As a way around, I used remote events to play the sounds from a server script but there’s a issue.
When the reload event is fired, the reload sound plays from everyone holding a gun instead of just the person that reloaded.

What I’m trying to achieve is to make the sound play only from the person who fired the event, how could I do this? I’m new to remote events.

Here’s the script that plays the reload sound.

game.ReplicatedStorage.ReloadSound.OnServerEvent:Connect(function()
local fireSound = script.Parent.Handle.Reload
	 
fireSound:Play() 
end)
1 Like

Do it in a serverscript like this

-- serverscript
--use
event:FireClient(player)

--localscript
event.OnClientEvent:Connect(function(player)
    --your code
end)
2 Likes

You could just reference the Player’s Character provided inside the OnServerEvent function, which actually holds the Player Instance who fired it

All you’d really need to do is just confirm & reference that the Player’s Character is holding the tool to play the sound:

game.ReplicatedStorage.ReloadSound.OnServerEvent:Connect(function(Player)
    local Character = Player.Character
    local Tool = Character:FindFirstChild("ToolObjectHere")

    if Tool then
        Tool.Handle.Reload:Play()
    end
end)
4 Likes

It will run the sound for the server though I think she/he wants it to play for only the LocalPlayer

I’m aware of that, playing it locally would only affect the client side & others won’t be able to hear the Reload sound

I think thats what he/she wants as I read

I want the sound to play for the server, anyone who is near the person that reloaded.

Thank you so much for replying, I’ll try the solutions now and report back when I’m done.

Ok I read wrong lol that is fine

This worked perfectly for me! Thank you so much for the solution, @JackscarIitt! This was a problem I struggled with for way too long, and thank you @FrazedGreatness2 for replying as well.

1 Like

Np I will be in any post you send I followed you :slight_smile:

I had this similar issue for hours, and @JackscarIitt response was the solution! I also added a character check ontop of the player check just to make sure it is the player. This was on the local script.