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

How to make sound ambients different for all players?

Hi! So recently I and my friend were building a cinema, and we would like to make different sound ambients for the outside and the inside. We made a script already, but it changes the ambients for everyone once a player touches the blocks with the script. Could anyone help making it local, just for the player which touches it?

Also here is the script we have now:

local plr = game.Players.LocalPlayer
function onTouched(hit)
		   if hit.Parent:FindFirstChild("Humanoid") then
			   game.Players.LocalPlayer.SoundService.AmbientReverb = Enum.ReverbType.ConcertHall
		   end
end

script.Parent.Touched:Connect(onTouched)

Thanks in advance!

1 answer

It looks like your script is a LocalScript which is good, however you are not checking to make sure that the person who touched it is the correct client. You should adjust your script to be more along these lines so it does not trigger when any client touches it, but rather only the main client.

local plr = game.Players.LocalPlayer
function onTouched(hit)
	local character = hit.Parent
        if character:FindFirstChild("Humanoid") and character == plr.Character then
           game.Players.LocalPlayer.SoundService.AmbientReverb = Enum.ReverbType.ConcertHall
        end
end

script.Parent.Touched:Connect(onTouched)

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