im trying to make a loading screen but i want to pause the main music while its going on. im checking to see if it becomes visible since when they press “start” it starts the loading sequence.
script:
local maintheme = game.SoundService:WaitForChild("FNAF Ultimate Custom Night Theme")
if script.Parent.Visible then
maintheme.Volume = 0
wait(3)
maintheme.Volume = 0.5
end
what happens is the script only works if i made it visible before pressing start. i want it so the script plays when it becomes visible.
Have you tried using GetPropertyChangedSignal to create an event listening for the Visible property, bound to a function to do this? Alternatively, wherever in your code is changing whether it’s visible or not, could it not do this functionality too?
im not aware of this feature. can you give me an example using the visible property? (Yes i see the post and its example but this would explain more to me)
function visibilityChanged(value) --true or false
if value then
maintheme.Volume = 0
task.wait(3)
maintheme.Volume = 0.5
end
end
local UIObject = script.Parent
visibilityChanged(UIObject.Visible)
UIObject:GetPropertyChangedSignal("Visible"):Connect(function()
visibilityChanged(UIObject.Visible)
end)
local maintheme = game.SoundService:WaitForChild(“FNAF Ultimate Custom Night Theme”)
function visibilityChanged(true) --true or false
if true then
maintheme.Volume = 0
task.wait(3)
maintheme.Volume = 0.5
end
end
script.Parent.Changed:Connect(function()
local s,f = (script.Parent.Visible == true then pcall(function() maintheme.Volume = 0 end) or pcall(function() maintheme.Volume = 0.5 maintheme:Play() end))
if f then
warn(f)
end
end)
If you’re playing the main music on the server, then just make its volume 0 as soon as the player joins in a LocalScript, then after the loading screen has finished loading, play it back up.