I made a script so when the player enters a certain part of the game the player walks slower and music plays, and when he's out everything stops. Everything works but the music fading in and out. Here's the script. The music part messed up the whole script, so where did I go wrong?
local scene = script.Parent local function steppedOn(part) local parent = part.Parent if game.Players:GetPlayerFromCharacter(parent) then parent.Humanoid.WalkSpeed = 2.5 wait(0.5) local S1 = Instance.new ("Sound",workspace) if S1 == true then local S1 = Instance.new ("Sound",workspace)== false end S1.SoundId = "rbxassetid://380808812" S1.Volume = 0 S1:Play() for i = 1,50 do wait(0.1) S1.Volume = S1.Volume + 0.05 end repeat wait() until S1.TimeLength > 20 wait(20) for i = 1,50 do wait(0.1) S1.Volume = S1.Volume - 0.05 end script.Parent:Destroy() parent.Humanoid.WalkSpeed = 16 scene.Touched:connect(steppedOn) end end