Hello!
I’ve been making a script, and I was wondering, how would I make a sound play for all clients / for server?
For example: A script in ServerScriptService plays a sound that everyone can hear.
Hello!
I’ve been making a script, and I was wondering, how would I make a sound play for all clients / for server?
For example: A script in ServerScriptService plays a sound that everyone can hear.
you can use
RemoteEvent:FireAllClients()
In what way could I use that? like, what part of a script would that be compatible with?
local sound = workspace.sound
sound:Play()
use a server script to play sounds in the workspace as posted
This will mean that everyone can hear it and if they join midsong it will be midsong for everyone due to the sound is being controlled by the server.
For example after activating a ProximityPrompt you can play a sound for all players in game like this:
Server Script in the ProximityPrompt
local Prompt = script.Parent
local RemoteEvent = game:GetService("ReplicatedStorage").PlaySounds --// You need to create a RemoteEvent in ReplicatedStorage named PlaySounds
Prompt.Triggered:Connect(function()
RemoteEvent:FireAllClients()
end)
LocalScript in StarterPlayer → StarterPlayerScripts
local RemoteEvent = game:GetService("ReplicatedStorage").PlaySounds
RemoteEvent.OnClientEvent:Connect(function()
local Sound = Instance.new("Sound")
Sound.SoundId = "rbxassetid://12345" --// Example ID
game:GetService("SoundService"):PlayLocalSound(Sound)
Sound.Ended:Wait()
Sound:Destroy()
end)
I’ll play the sounds from the player… I made a mistake in this post, I want the sound to have proximity, not to be heard by anyone.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.