#number attribute containing a value is returned as nil

1 messages · Page 1 of 1 (latest)

queen shoal
#
if chairs[i].Seat.Occupant == player.Character.Humanoid then --finds the chair which the player is on
print("c") --is printed
local chC = chairs[i]:GetChildren()
  for j = 1, #chC do
    print("d") --is printed
      if chC[j]:IsA("Part") and chC[j].Name ~= "Part" then --find the part which have the attribute
        print("e") --is printed
        local id = chC[j]:GetAttribute("id")
        print(id) --prints nil
        exampleFunction(id)
        break
      end
    end
  break
end

i have this script which executes a function that uses an ID related to a chair which the player who triggered the event is on as parameter, the thing is the GetAttribute("id") always return nil, i have tried different approaches like putting the ID on the name instead, and it always return nil

✅ there is only one part which name is not "Part", but there is Union and Seat, havent tested if they are the problem
✅ the part have an attribute called id
✅ the id attribute has a number as value
❌ GetAttribute returns nil and therefore, sends "nil" to the function

queen shoal
#

solved, chC[j].Name ~= "Part" wasnt being abble to find it somehow, changing it to string.find(chC[j].Name, pattern) solved

twilit mica
#

@queen shoal