Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why wont the sound for individual players work?

How do I make individual player hear a sound that is in the player or character?

I keep ending up doing it wrong.

1 comment

0

Play it from a local script with FilteringEnabled.

2 answers

If FilteringEnabled is on, create the sound from the client and play it there. If not, use PlayLocalSound, a function of SoundService

##How Can You Solve Your Problem

To solve your problem, you can use Filtering Enabled or Experimental Mode off. They are both the same things. Then, we will use a Remote Event

##What is Filtering Enabled?

Filtering Enabled changes the system architecture to make your games secure.

###What Is System Architecture?

System Architecture is how the system works. To be more specific, the communication between the client and server and vice versa.

###Experimental Mode's System Architecture:

Whatever the client gives, the server accepts. This might sound innocent enough, however, if an exploiter were to have a walkspeed increase script. The server would listen and everyone will have to see that.

###Filtering Enabled System Architecture

Like said in the Experimental Mode's system architecture, the server listens to everything the client gives. In this system architecture, it does the opposite. The server blocks of everything from the client.

##How Would The Server Know That A Script Isn't an Exploit?

You could use Remote Events, Remote Functions, Bindable Events, and Bindable Functions.

Right now, we are focusing on Remote Events

First of all, enable Filtering Enabled. To do this, go onto Workspace and find the Filtering Enabled property(don't worry, this is read-only which means that you cannot change this in a script. You could change this property by the command bar or with plugins).

##How to use Remote Events To use Remote Events, we have 2 events called OnServerEvent(Player player, tuple arguments) and OnClientEvent(tuple arguments). For now, we are going to use OnClientEvent.

Client

--\\ Services
local repStorage = game:GetService("ReplicatedStorage")
--\\ Network Data
local soundRemote = Instance.new("RemoteEvent")
soundRemote.Name = "SoundRemoteEvent"
soundRemote.Parent = repStorage -- let's call our remote event Sound Remote Event
--\\ Sound
local sound = repStorage:WaitForChild("Sound") -- you can call your sound whatever you want, just make sure you change the name of the actual sound

--\\ Play Sound Client
soundRemote.OnClientEvent:Connect(function()
	sound:Play()	
end)

The sound variable might have Looping to true

Since we have our client, now, let's communicate between the client and server. To do this, we have three methods, FireClient(Player player, tuple arguments), FireAllClients(tuple arguments), and FireServer(tuple arguments).

We will use FireClient() Since we want it to fire for one player.

Server

--\\ Services
local repStorage = game:GetService("ReplicatedStorage")
--\\ Network Data
local soundRemote = soundRemote:WaitForChild("SoundRemoteEvent")
--\\ Fire Client
game.Players.PlayerAdded:Connect(function(player)
	soundRemote:FireClient(player)
end)

There is much more to Filtering Enabled and it will give you a headache(trust me). Hopefully this had helped you

This discussion is preserved as it was. New answers, comments, and votes are closed.