I got some audios inside a tools and if I play from a local script others players dont gonna listen. So I tried to use remote events but I dont understand too much about remote events so I did something like this:
--Local script:
game.ReplicatedStorage.GunSounds:FireServer(Gun_Sound)
--ServerScriptService
game.ReplicatedStorage.GunSounds.OnServerEvent:Connect(function(sound)
sound:Play()
end)
2 Likes
JoelBrd
(Joel)
September 12, 2021, 4:31pm
#2
What is ‘Gun_Sound’?
You may be telling the server to play a sound that only exists on the client.
D0RYU
(nici)
September 12, 2021, 4:32pm
#3
--Local script:
game.ReplicatedStorage.GunSounds:FireServer(Gun_Sound)
--ServerScriptService
game.ReplicatedStorage.GunSounds.OnServerEvent:Connect(function(player, sound)
sound:Play()
end)
try this
4 Likes
crazyEjai
(Giyu)
September 12, 2021, 4:37pm
#4
I think you need to use the sound ID inside the script to make it work though.
1 Like
thats works I didnt know about player,
1 Like
D0RYU
(nici)
September 12, 2021, 4:38pm
#6
you can pass instances through remotes
D0RYU
(nici)
September 12, 2021, 4:42pm
#7
when working with remote events you have to do it like this
FireServer
RemoteEvent:FireServer(Data)
RemoteEvent.OnServerEvent:Connect(function(Player, Data)
end)
FireClient
RemoteEvent:FireClient(Player, Data)
RemoteEvent.OnClientEvent:Connect(function(Data)
end)
if you look at the parameters and arguments you can see Player
and Data
in your case sound
is the data being sent
EDIT:
fixed code
2 Likes