Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Audio script not stopping the audio????

Asked by 5 years ago

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

Log in to vote
0
Answered by
Hypgnosis 186
5 years ago
Edited 5 years ago

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.

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 killerbrasko2002 33 — 5y
Ad

Answer this question