I am making a script in which I have a model of 10 bricks or so and the bricks have a Decal in them in which a decal texture in inputted and it displays like a real life Order Menu. If I correctly select an item that is on that "Order Menu" it is to remove the texture and then move any other textures that were in front of the one back by one brick so it stays in order.
My issue is that in trying to call the next proceeding brick I spawn a new Part and name it the value of the brick and then try to compare it with a for loop, the problem is the if statement does not seem to be working.
local z = 0
local ItemID = game.Workspace.ReferenceDecal.Texture
local model = game.Workspace.Board:GetChildren()
for i, v in pairs(model) do
local decal = v:FindFirstChild("Decal")
if decal then
if decal.Texture == ItemID then
decal.Texture = "" --Removes Decal
local moveAmount = game.Workspace.OrderBoard.Counter.Value - tonumber(v.Name)
for z = 1, moveAmount do
local nextBrickPlaceHolder = tonumber(v.Name + z)
local spawnNewBrickWithSameName = Instance.new("Part", game.Lighting)
spawnNewBrickWithSameName.Name = nextBrickPlaceHolder
local decalPlaceHolder = ""
if v.Name == spawnNewBrickWithSameName.Name then
decalPlaceHolder = v.Decal.Texture
end
decal.Texture = decalPlaceHolder
end
break
end
end
end
