Issue with change image

So I have had an issue with this before but this is odd so my code is:

local player = game.Players.LocalPlayer
local button = script.Parent

button.MouseButton1Up:Connect(function()
player.PlayerGui.Main.Settings.BackgroundImageSet.Image = “rbxassetid://9330937417”
end)

Output:

Main is not a valid member of PlayerGui “Players.3DRobloxGameDev.PlayerGui”

1 Like

Try using WaitForChild

player:WaitForChild("PlayerGui"):WaitForChild("Main"):WaitForChild("Settings").BackgroundImageSet.Image = “rbxassetid://9330937417”

You always find me lol but this didn’t work and the output says

Infinite yield possible on ‘Players.3DRobloxGameDev.PlayerGui:WaitForChild(“Main”)’

1 Like

Hmmm it’s a little weird, I thought by the time the user clicks the button the player and descendants must be loaded in. It’s pretty hard to click the button before player loads in, right?

Are you sure “Main” is a thing in PlayerGUi

its in starergui in a screengui

Press Play and send a screen clipping of playerGui and it’s descendants

is clipping and descendants in properties of it

If its a local script in starter gui, i think you should do a

repeat wait() until player:FindFirstChild("PlayerGui")

I meant could you please send a screenshot of ingame whilst playing of PlayerGui

the button is inside a frame of a screengui and the local script is inside the button


the output is delayed when i click the button

With the code I’m talking about:

repeat wait() until player:FindFirstChild("PlayerGui")

button.MouseButton1Up:Connect(function()
player.PlayerGui.Main.Settings.BackgroundImageSet.Image = “rbxassetid://9330937417”
end)

Though this may not work, if that’s not the case you should send us (more specifically @TheZanderius ) an image of the playergui tree.

I meant the explorer, of playerGUI, Like this:
image

explorer

thx didn’t work though output said:

Players.3DRobloxGameDev.PlayerGui.ScreenGui.Main.Settings.Button.LocalScript:4: Expected identifier when parsing expression, got Unicode character U+201c (did you mean ‘"’?)

Yeah, so “Main” is not a child of PlayerGui, that’s why it is not working

1 Like

So, you’re getting the path wrong. That’s what it sounds like, this should help.

repeat wait() until player:FindFirstChild("PlayerGui")

button.MouseButton1Up:Connect(function()
player.PlayerGui:FindFirstChild("name of the screengui").Main.Settings.BackgroundImageSet.Image = "rbxassetid://9330937417"
end)

Also, why was the quotations a different character unicode?

Yeah I don’t know if their unnamed “ScreenGui” is main. If so they should just rename ScreenGui to Main

1 Like

there is only 1 screengui then the main (main being frame.)