Decals Is Not A Valid Member Of Part

So I’m trying to program decals so an image is shown and then after a while it gets destroyed and another image takes it’s place. I have a part in the workspace named Screen. I put the script and decals as the children of screen. Whenever I run the game an error shows up saying that decals is not a valid member of part.

local A = game.Workspace.Screen.Decals.A
local B = game.Workspace.Screen.Decals.B
local C = game.Workspace.Screen.Decals.C
local D = game.Workspace.Screen.Decals.D
local English A = game.Workspace.Screen.Decals.EnglishA
local English B = game.Workspace.Screen.Decals.EnglishB
local English C = game.Workspace.Screen.Decals.EnglishC
local English D = game.Workspace.Screen.Decals.EnglishD


while true do
	
	local newFirstDecal = A:Clone()
	newFirstDecal.Parent = Screen
	
	wait(2)
	newFirstDecal:Destroy()
	
	local newSecondDecal = English A:Clone()
	newSecondDecal.Parent = Screen
	
	wait(2)
	newSecondDecal:Destroy()
	
	local newThirdDecal = B:Clone()
	newThirdDecal.Parent = Screen
	
	wait(2)
	newThirdDecal:Destroy()
	
	local newFourthDecal = English B:Clone()
	newFourthDecal.Parent = Screen
	
	wait(2)
	newFourthDecal:Destroy()
	
	local newFifthDecal = C:Clone()
	newFifthDecal.Parent = Screen
	
	wait(2)
	newFifthDecal:Destroy()
	
	local newSixthDecal = English C:Clone()
	newSixthDecal.Parent = Screen
	
	wait(2)
	newSixthDecal:Destroy()
	
	local newSeventhDecal = D:Clone()
	newSeventhDecal.Parent = Screen
	
	wait(2)
	newSeventhDecal:Destroy()
	
	local newEighthDecal = English D:Clone()
	newEighthDecal.Parent = Screen
	
	wait(2)
	newEighthDecal:Destroy()
	
	
	
end

Thanks for reading :grinning:

I noticed you have some variable names with spaces, for example English A. You can’t do this in lua (or really any language for that matter). Make sure your variable names contain no spaces. So do EnglishA instead.

1 Like

Do you have the decals inside a folder named Decals or something?

No its in the part, screen. Charrr

Can I see a screenshot of your workspace?

1 Like

Decals is not a folder in screen. That is why it is erroring.

2 Likes

The rules of all variable names are simple. Just to highlight some of them:

  • No whitespaces
  • Always begin with letters, not numbers

To index them, you could…

-- wow variables changed, change everything else as well
local EnglishA = game.Workspace.Screen["English A"] 
local EnglishB = game.Workspace.Screen["English B"]
local EnglishC = game.Workspace.Screen["English C"]
local EnglishD = game.Workspace.Screen["English D"]

However, it’s probably more conventional to do this:

-- Keep the names, but change the name of the objects.
local EnglishA = game.Workspace.Screen.EnglishA
local EnglishB = game.Workspace.Screen.EnglishB
local EnglishC = game.Workspace.Screen.EnglishC
local EnglishD = game.Workspace.Screen.EnglishA

In computer science, directory of objects are important. Make sure you don’t misconceive the concepts of finding objects in a workspace.

3 Likes

In a folder like this?

In your script to access a decal you did game.Workspace.Screen.Decals.A. Inferring that there is an object called Decals in Screen. In the previous screenshot there was no object called Decals. That will work as long as you rename the folder to Decals

1 Like

Thanks, I just noticed that. I changed decals to folder.

Also your code can be simplified a lot.

local Decals = {
    A = game.Workspace.Screen.Decals.A,
    English A = game.Workspace.Screen.Decals.EnglishA,
    B = game.Workspace.Screen.Decals.B,
    English B = game.Workspace.Screen.Decals.EnglishB,
    C = game.Workspace.Screen.Decals.C,
    English C = game.Workspace.Screen.Decals.EnglishC,
    D = game.Workspace.Screen.Decals.D,
    English D = game.Workspace.Screen.Decals.EnglishD
}

while true do
    for _,decal in ipairs(Decals) do
        local newDecal = decal:Clone()
        newDecal.Parent = Screen

        wait(2)

        newDecal:Destroy()
    end
end
1 Like

I tested this version instead, placing all decals in a folder.

local Screen = workspace.Screen
local DecalsFolder = Screen.Decals
local Decals = {
	DecalsFolder.A, DecalsFolder.EnglishA, 
	DecalsFolder.B, DecalsFolder.EnglishB, 
	DecalsFolder.C, DecalsFolder.EnglishC, 
	DecalsFolder.D, DecalsFolder.EnglishD
}

while true do
	for _, decal in next, Decals do
		local decalClone = decal:Clone()
		decalClone.Parent = Screen
		
		wait(2)
		decalClone:Destroy()
	end
end
2 Likes