I already put a part in the room so they can’t hear ambience and after they got out they should hear the ambience back again.
-- The "if not hit.Parent:FindFirstChild("Humanoid") then" statment is the problem I'm having with.
music = script.Parent
music.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
music.Parent.Ambience1:Pause()
if not hit.Parent:FindFirstChild("Humanoid") then
music.Parent.Ambience1:Play()
wait(1)
end
end
end)
local TweenService = game.TweenService
music = script.Parent
Debounce = false
WaitTime = 2
InRoom = false
local T = TweenInfo.new(1)
music.Touched:Connect(function(hit)
if not Debounce and hit.Parent:FindFirstChild("Humanoid") then
Debounce = true
InRoom = not InRoom
if InRoom == false then
TweenSevice:Create(music.Parent.Ambience1, T, {Volume = 0}):Play()
else
TweenSevice:Create(music.Parent.Ambience1, T, {Volume = 0.5}):Play()
-- if Player leaves
end
task.wait(WaitTime)
Debounce = false
end
end)
It didn’t work when I went inside the first time, and when I went out and went back in the second time it works. Maybe I need some parts to play the ambience so the first time it can work or something else.
local TweenService = game.TweenService
music = script.Parent
Debounce = false
WaitTime = 2
InRoom = false
local T = TweenInfo.new(1)
music.Touched:Connect(function(hit)
if not Debounce and hit.Parent:FindFirstChild("Humanoid") then
Debounce = true
InRoom = not InRoom
if InRoom == true then
TweenSevice:Create(music.Parent.Ambience1, T, {Volume = 0}):Play()
else
TweenSevice:Create(music.Parent.Ambience1, T, {Volume = 0.5}):Play()
-- if Player leaves
end
task.wait(WaitTime)
Debounce = false
end
end)
When I went inside it worked the first time and then when I went outside the ambience didn’t come back. Should you use Region3 too or no? I forgot to say the 2 TweenServices are missing an r.