Basically, I want the sound to play if it meets the condition that IsActive is equal to 0. This works inside of testing mode on studio but does not when I play normally.
I already tested until the PlayerGui actually loaded.
--localscript inside of StarterGui>ScreenGui --IsActiveInt is an integer value in Workspace local player = game.Players.LocalPlayer local menusound = script.PausedSound local clicksound = script.ClickSound IsActiveInt = game.Workspace.IsActive.Value local PlayButton = script.Parent.Frame.MainMenu.PlayButton local ShopButton = script.Parent.Frame.MainMenu.ShopButton local TutorialButton = script.Parent.Frame.MainMenu.TutorialButton local LoadingScreen = script.Parent.Frame.LoadingScreen wait(3) function check() if IsActiveInt == 0 then menusound:Play() end end check()
Thank you, Gianni
The parent of an object always loads before the child, so using .Parent
is always fine. However, when you're trying to access a child of an object, use WaitForChild
unless you know it's loaded.
local player = game.Players.LocalPlayer local menusound = script:WaitForChild("PausedSound") local clicksound = script:WaitForChild("ClickSound") IsActiveInt = workspace:WaitForChild("IsActive")--removed .Value local Frame = script.Parent:WaitForChild("Frame") local MainMenu = Frame:WaitForChild("MainMenu") local PlayButton = MainMenu:WaitForChild("PlayButton") local ShopButton = MainMenu:WaitForChild("ShopButton") local TutorialButton = MainMenu:WaitForChild("TutorialButton") local LoadingScreen = Frame:waitForChild("LoadingScreen") wait(3) function check() if IsActiveInt.Value == 0 then-- Added .Value menusound:Play() end end check()
I hope I helped!
Good Luck!