You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
Hello, I want to iterate through a table that has a column with spaces, check their ‘Occupied’ Attribute to see if it is occupied, and if it isn’t, change the space’s transparency and color to mark it as a player’s find 4 puck for their turn -
What is the issue? Include screenshots / videos if possible!
I keep getting an error that says 'attempt to call missing method of GetAttribute of table whenever I try and access the currently selected index’s attribute -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried looking on the Dev forums and the api relating to tables, I did see one called ‘table.foreach’, that I thought would’ve worked, but I realized it is deprecated when I attempted to put it in the code.
I’ve also tried using ‘GetChildren’ and ‘GetDescendants’ with the same error. Before switching to attributes, I also attempted to get a boolvalue child under each space as well, but that also results in the same error.
Here is the code as it currently stands:
--Variables
local clickdetector = script.Parent.ClickDetector
local Column = script.Parent
local debounce = false
local Player = game.Workspace.PlayerTurn
local CPU = game.Workspace.CPUTurn
SelectedColumn = Column.SelectedColumn
local Spaces = {
Space1 = Column.Space1,
Space2 = Column.Space2,
Space3 = Column.Space3,
Space4 = Column.Space4
}
clickdetector.MouseClick:Connect(function()
if not debounce then
SelectedColumn.Value = true
for k,v in pairs (Spaces) do
local CheckOccupied = Spaces:GetAttribute("Occupied")
print("Check1")
if false then
Spaces:SetAttribute("Occupied", true)
if Player then
print("Check3")
Spaces.Transparency = 0
Spaces.BrickColor = Spaces.BrickColor.new ("Bright Blue")
else
Spaces.Transparency = 0
Spaces.BrickColor = Spaces.BrickColor.new("Persimmon")
end
end
end
end
end)
Also, here is what it looks like in the explorer and a visual representation in game