BackgroundImage is not a valid member of Frame "SelectedFrame"

Hello, I have a script

local Players = game:GetService("Players")

local player = game:GetService("Players").LocalPlayer
local PlayerGui = player.PlayerGui
local Camera = workspace.CurrentCamera
Character = Players.LocalPlayer.Character

local Players = game:GetService("Players")
local client = Players.LocalPlayer

script.Parent.Parent.TextButton.MouseButton1Click:Connect(function(player) --Changed ClickDetector to TextButton
PlayerGui.YourGui.YourText.PreloadB.Disabled = false

When the script is executed I get this error:


I’m unsure what is causing this error in the script, I’ve tried readjusting/rescripting things. The script is meant to remove a GUI from a player’s screen and then execute a local script inside a GUI.

Any help is appreciated, thanks! :blush:

1 Like

I do have a couple of things to suggest:

  • You seem to be defining the LocalPlayer twice…? You should just keep it as 1

  • Character is a global variable & not secured with a CharacterAdded:Wait(), do change it to “local”

  • There’s no parameter for MouseButton1Click

Try this perhaps?

local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local PlayerGui = Player:WaitForChild("PlayerGui")

    PlayerGui.YourGui.YourText.PreloadB.Disabled = false

It would also help to see the hierarchy of what your Explorer looks like (Specifically inside your PlayerGui)

Could I see the explorer please?

A frame does NOT have the property background image. It’s background transparency.

The error is unrelated to the code you posted, as ‘BackgroundImage’ is not referenced inside it. Nevertheless, Frame objects do not have any kind of ‘Image’ property, so it’s possible you were trying to reference Frame.BackgroundColor or Frame.BackgroundTransparency and mistyped?

Just wanted this to be here for anybody who accidently came across the same problem, (yup that’s right apologies for the bump, I exist, yes :wave:).

The error is a CoreGui error, it’s saying it can’t find something because it’s missing. It would be appreciated if people would reply to a question with full knowledge of OP’s error and actually read into what they’re saying!

Your code has
this will actually destroy PlayerGui.
Remove one parent from the statement:
and that could fix it.

I had this exact issue because I was destroying PlayerGui instead of Gui (variable naming is hard for me.)