Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Sounds only plays on client?

Asked by 6 years ago
Edited 6 years ago

So I made a ragdoll scripts which triggers a function where It plays a sounds everytime a ragdolled character collides with any surface, and Its ID deppends of the strength of the collision. The problem I got is that the sound played is only heard by the player, so if another player sees the other one collide, they can't hear the sound.

Do you know how to fix it?

I'll leave my script here. The "part" parameter are for the body parts of the character, such as the arms or the torso.


function playSound(part,intensity,bool) if bool then local sound = Instance.new("Sound",part) sound.PlaybackSpeed = math.random(8,12)/10 if intensity < 5 then sound.SoundId = "http://www.roblox.com/asset/?id=131237241" sound.Volume = intensity/5 elseif intensity < 10 then sound.SoundId = "http://www.roblox.com/asset/?id=74388682" sound.Volume = 1 elseif intensity < 50 then sound.SoundId = "http://www.roblox.com/asset/?id=1159504677" sound.Volume = 1 else sound.SoundId = "http://www.roblox.com/asset/?id=314390675" sound.Volume = 3 end sound:Play() bool = false wait(0.4) bool = true wait(1.6) sound:Destroy() end end
0
really? sounds are replicated from client to server theking48989987 2147 — 6y
0
yep. By the way, the script is a localscript. Does that have something to do with sounds played only locally? masterjosue1998 116 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

The newer Roblox no longer replicates sounds and things coming from a client (due to exploiters) so they fixed this issue by using "FilteringEnabled." So basically anything that is done in the client side (localscripts and such) doesn't show up for anyone but the client. You use things such as "ServerEvents" and "ServerFunctions." They both do the same thing but are slightly different.

"ServerEvents" and "ServerFunctions" are used to call scripts that the server handles and replicates throughout the clients. They are very easy to learn and such (although you must learn them if you want your game to actually show up on the main page).

Here are super great tutorials for using them (thanks to AlvinBLOX): https://www.youtube.com/watch?v=wic-N4JiFss&amp;t=534s https://www.youtube.com/watch?v=-KqiPiE5P74

If you have any questions or issues, please contact me (In case you didn't understand the tutorials). ;)

Ad
Log in to vote
0
Answered by 6 years ago

Ok. I have read about It, and I understood how It works. However, the only issue I'm having is to execute It as a coroutine.

I mean, are you able to create a coroutine with ":FireServer()" ?

0
Yes, but probably not the way you are thinking about. You can set up a coroutine on the script that runs when a server is fired. lazycoolboy500 597 — 6y
0
I also thank you for showing me coroutines. I was looking into that a while back ago but didn't know if Roblox had something for it. lazycoolboy500 597 — 6y
0
Nevermind, It was simple as creating a new function with that line, and then putting it into a coroutine xd. Thanks for the help, It works perfectly now! masterjosue1998 116 — 6y

Answer this question