Question about attributes

So recently I have been trying to check if an attribute is equal to a value but it’s not working here is my if statement:

if pet:GetAttribute('PetNum') == 1 then
   print('Yes')
end

But it does not pring ‘Yes’. How do I fix this?

Thank you!

1 Like

It could be that PetNum is not one, try printing the attribute’s value before the condition

print(pet:GetAttribute("PetNum"))

if pet:GetAttribute('PetNum') == 1 then
   print('Yes')
end
3 Likes

Everything is correct here, so the only explanation is that the attribute doesn’t exist, or at least when the code is executed.

2 Likes

Oops, that was my bad I spelled it PetNum instead of PetNumber :slight_smile: .

2 Likes

What about putting pet:GetAttribute("PetNum") into a variable, and then checking the variable?

1 Like

I doubt that’d change anything.

1 Like

True. I mean, sometimes it could somehow work.

1 Like

It’s okay haha, sometimes we all make mistakes when naming things, hell sometimes I can forgot to put .Value, but in the end it’s all fixed! If you have anymore issues don’t be afraid to make another post!

2 Likes