I am making a script that make music play when you enter the game... I want the script to make the music stop when you press the begin (gui button). But when i test the game the music stop 1.5 seconds after i join the "test" game.
Here is the script:(local script i put inside the gui button)
local OpenSound = Instance.new("Sound", game.Workspace) local begin = script.Parent OpenSound.SoundId = "rbxassetid://1837482907" wait(0.5) OpenSound:Play() wait(1) repeat wait(1) if begin.MouseButton1Click:connect() then OpenSound:Stop() else wait(1) end until OpenSound:Stop() == true
You have many errors in your script. That errors on from 10 to 16 lines. You used repeat wrong
local OpenSound = Instance.new("Sound", workspace) local BeginButton = script.Parent OpenSound.SoundId = "rbxassetid://1837482907" wait(.5) OpenSound:Play() BeginButton.MouseButton1Click:Connect(function() if OpenSound then wait() OpenSound:Stop() end end)