I want to change the SoundService's AmbientReverb property to NoReverb when it was previously Hallway, and Hallway when it was previously reverb. This script works if you remove the else if and just write "else Sound.AmbientReverb = "Hallway"" so it seems as though the if statement never evaluates to true. Can anyone help here?
function onTouch(part)
local player = game.Players:GetPlayerFromCharacter(part.Parent)
if player then
local human = part.Parent:findFirstChild("Humanoid")
if human then
Sound = game:GetService("SoundService")
if Sound.AmbientReverb == "Hallway" then
Sound.AmbientReverb = "NoReverb"
elseif Sound.AmbientReverb == "NoReverb" then
Sound.AmbientReverb = "Hallway"
end
end
end
end
script.Parent.Touched:connect(onTouch)

4 comments
Spotted a quotation mark left out from the previous script's string on line 3. Also, shouldn't line 2 and 4 have "Enum.ReverbType." too, instead of a string?
This worked fine, thanks!
Spongocardo: (You're right about the quote) When you are setting, most of the Enum values let you set friendly values, and it does the conversion for you. Comparing is where you need to be exact.
@BlueTaslem Well, I learn something new everyday. Thanks again.