Hello everyone,
I am having trouble with a script I recently made. It is a localscript
, just not sure why it isn’t working.
The Script: (game.StarterGui | localscript)
local part = game.Workspace.CafeDoor
local sounds = game.Workspace.Sounds
local db = false
local lobbymusic = true
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local plrwhohit = game.Players:GetPlayerFromCharacter(hit.Parent)
if plrwhohit == game.Players.LocalPlayer then
if db == false then
db = true
if lobbymusic == true then
lobbymusic = false
for i = 0.2,0,-0.01 do
wait()
for i,v in pairs(sounds.Music:GetChildren()) do
if v:IsA("Sound") then
v.Volume = i
end
end
end
for i = 0,0.2,0.02 do
wait()
for i,v in pairs(sounds.CafeMusic:GetChildren()) do
if v:IsA("Sound") then
v.Volume = i
end
end
end
else
lobbymusic = true
for i = 0.2,0,-0.01 do
wait()
for i,v in pairs(sounds.CafeMusic:GetChildren()) do
if v:IsA("Sound") then
v.Volume = i
end
end
end
for i = 0,0.2,0.02 do
wait()
for i,v in pairs(sounds.Music:GetChildren()) do
if v:IsA("Sound") then
v.Volume = i
end
end
end
end
wait(3)
db = false
end
end
end
end)
It seems that when I touch the part, the soudns inside of the “Music” folder get really loud, and the sounds in the “CafeMusic” folder get a bit louder than before. Nothing fades, and upon touching the part a second time nothing happens.
Let me know what you think!
Thanks,