Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Audio script not stopping the audio????

This is the script i have so far its not working (ive tried local and non local) (right now its in serverscript service but ive tried remote events, and putting it in the GUI and the audio still wont work) So what would fix this script?

game.StarterGui.Menu.Main_Menu.Menu_Background.Play_Button.Button.MouseButton1Click:Connect(function()
	print ("1")
	game.StarterGui.Menu.Sound2.Looped = false
	print ("2")
	game.StarterGui.Menu.Sound2.Playing = false
		print ("Music off")
	end)

1 answer

✓ Accepted answer

First of all, you can't do anything with guis in a server script (to my knowledge), so go back to a local script.

Secondly, StarterGui replicated to PlayerGui, which is in the Player. This means any changes made to the StarterGui in a script will do NOTHING. You need to access the PlayerGui and change it through there. To do so:

local Player = game:GetService('Players').LocalPlayer
local PlayerGui = Player:WaitForChild('PlayerGui')

PlayerGui.Menu.Main_Menu.Menu_Background.Play_Button.Button.MouseButton1Click:Connect(function()
    print ("1")
    PlayerGui.Menu.Sound2.Looped = false
    print ("2")
    PlayerGui.Menu.Sound2.Playing = false
        print ("Music off")
end)

TLDR: In scripts, access guis through PlayerGui, NOT StarterGui.

Let me know if you have any questions or if my provided code isn't working.

1 comment

0

Hey, thanks for the help i think you had the right idea, but this did not work, i put it inside the pressed button, it did print but did not take action, im not sure why, please respond if you have time

This discussion is preserved as it was. New answers, comments, and votes are closed.