Local sound issue

Hey guys I know this issues been covered but please hear me out as nothing ive seen suggested works.

Background: Im making a game with portals. Each portal sends you to a different world(same server though no external teleport). Each world has its own music.

The problem: i want it to be multiplayer but I cant because anytime a song plays that should be for you locally, everyone hears it. Ive tried writing the code in localscripts that go into the parts themselves, and also localscripts into startplayer, startergui, ect. Everyones music still jumbles on top of eachother. I tried using omclient remote events, didnt work.

I learned from roblox documentation of a feature called “PlayLocalSound()” it claims sounds cannot be client based without this (idk of thats true or not). I tried it, still didnt work, the sounds are heard by the entire server. So im not sure what to do. Is this a roblox issue? Or am I missing something?

Please dont answer with sarcastic or rude comments I just want help and I did try hard to look for an answer before posting this.

2 Likes

Maybe SoundService.RespectFilteringEnabled is off? Just guessing, try turning it on.

1 Like

Thanks for the quick response. I did try that out too and it didnt work. I should add, I had a scripter try to help me too and they gave up lol.

Just a quick suggestion: have you tried putting the sound in the client’s camera?

So I’m guessing you got a folder or something in workspace with all different musics in it. You are using a localscript to play the right one, and everyone else hears it as well?

1 Like

No i havnt tried that actually would that work?

Yeah, thats how i have it setup

Maybe the sounds are set to Playing = true by default, or maybe you have forgotten about a server script you maybe made to play the music?

1 Like

I actually do have all the songs playing to true, would that make it so they cant be local? Sorry i hadnt thought of that

Haha that makes them all play when the game starts

1 Like

Wait sorry i misunderstood, i dont have that set then. I just changed them to true in the localscripts

You play them all at once in the localscript or what do you mean?

1 Like

I have it so that once you enter a particular world, in that script that takes you to the world, the song is also set to play and once you leave, i have it so it stops

Try playing and see if only one sound is playing or if many of them are.

1 Like

I have it so when you join you just hear wind, thats working fine no other music. When you join a world, its respective music plays as well like it should. Its just everyone hears it and songs get jumbled together if other people join diff worlds

I honestly have no idea what is wrong. Are you sure it’s played locally and not on server?

1 Like

Ikr thats what im saying it just defies logic lol. But yeah i have my brother test it with me and anytime I tried things wed still hear eachothers music cross over eachother. Idk what to do

I think PlayLocalSound() is meant more for Studio plugins to be able to play sound in the editor, not really for game use.

If you’re relying on touched events, make sure otherPart from the Touched event belongs to the local player. You can do it like this:

local Players = game:GetService("Players")

local part = (reference the part here)

local function onTouched(otherPart)
    local player = Players:GetPlayerFromCharacter(otherPart.Parent)
    if player and player == Players.LocalPlayer then
        -- put your code here
    end
end

part.Touched:Connect(onTouched)

By the way, LocalScripts only run in specific places. They don’t run in Workspace unless they are parented to the local player’s character. You will want to use a Script with its RunContext set to Client, if you want to have a script running locally parented to a part.

I also thought maybe the localscript picks up when other players change worlds. Can you send the localscript which plays the music for me to take a look?

1 Like

Ill try that out that seems more promising than what ive tried.