This script is just so simple that i can’t really figure out what it’s wrong with it, it works (kind of) while using it on the ServerSide but while doing it in a LocalScript the only Print that works its the AmbientFolder
local AmbientFolder = workspace:WaitForChild("AmbientSounds",2)
local TweenS = game:GetService("TweenService")
local ActSound = nil
print(AmbientFolder)
local function TweenSound(ActualSound,nextSound,SoundVolume)
print("function")
if ActualSound ~= nil then
local s1 = TweenS:Create(ActualSound,TweenInfo.new(1),{Volume = 0})
s1:Play()
s1.Completed:Wait()
end
local s2 = TweenS:Create(nextSound,TweenInfo.new(1),{Volume = SoundVolume})
s2:Play()
ActSound = nextSound
end
for _,soundPart in AmbientFolder:GetChildren() do
if not soundPart:IsA("BasePart") then continue end
print("soundPart")
local MaxVolume = soundPart:WaitForChild("Sound").Volume
soundPart.Touched:Connect(function()
if ActSound == soundPart.Sound then return end
print("Touched")
soundPart.Sound:Play()
TweenSound(ActSound,soundPart.Sound,MaxVolume)
end)
end
for _,soundPart in AmbientFolder:GetChildren() do
if soundPart:IsA("BasePart") then
print("soundPart")
local MaxVolume = soundPart:WaitForChild("Sound").Volume
soundPart.Touched:Connect(function()
if ActSound == soundPart.Sound then return end
print("Touched")
soundPart.Sound:Play()
TweenSound(ActSound,soundPart.Sound,MaxVolume)
end)
end
end