LocalScript Not Changing GUI

  1. What do you want to achieve?
    I want the image and text in the Gui to change when clicked. This is for a mute button.
  2. What is the issue?
    It isn’t changing at all. It successfully mutes/unmutes the audio, but doesn’t change the Gui.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I checked the script for obvious errors and don’t see any. I looked for solutions and only found one thing, it was a tutorial for something similar. The code was very similar, didn’t work.

Image and script below

mutebutton

local music = game.Workspace.Music
local muteText = game.StarterGui.MuteButton.TextLabel
local muteImage = game.StarterGui.MuteButton.TextLabel.ImageButton

script.Parent.MouseButton1Click:Connect(function()
	if music.Volume == 1 then
		music.Volume = 0
		muteText.Text = "Unmute"
		muteImage.Image = "rbxassetid://6853258454"
	else music.Volume = 1
		muteText.Text = "Mute"
		muteImage.Image = "rbxassetid://166376559"
	end
end)

If I didn’t give enough info or formatted this weird, apologies. This is my first post.

1 Like

try this. It should work since you need to change the player’s UI.

3 Likes

StarterGui does not affect the player, as all gui within startergui get replicated to the PlayerGui instance that can be accessible from a local script inside StarterGui using script.Parent (it will trigger the screenGUI cause all gui will be moved to the player instance). Here is an example:
image
Testing gui i made
image
all gui instances from startergui are replicated into the player! if you need any more help let me know.

2 Likes

Thank you so much! I knew it would be something small I missed.

1 Like

No problem!! I remember I always use to do this mistake. Take’s a lot of time to get used to it :slight_smile:

1 Like

Ah okay. Thanks for the explanation.

1 Like