How can I create an if statement to check if an attribute does not have any value?

I am trying to check if my attribute CarName has no value.
What I’ve tried

if plr.Car.CarVals:GetAttribute("CarName", "") then
print("NO VALUE")
2 Likes
if (plr.Car.CarVals:GetAttribute("CarName") == nil or plr.Car.CarVals:GetAttribute("CarName") == "") then
print("NO VALUE")
end
2 Likes

if plr.Car.CarVals:GetAttribute(“CarName”) == “” then
print(“NO VALUE”)
end

2 Likes

Try this:

if plr.Car.CarVals:GetAttribute("CarName") and plar.Car.CarVals:GetAttribute("CarName") == "" then
    print("No value.")
end

This checks if the attribute exists with the name CarName, then checks for the value.

2 Likes

@DiamondDrencher1 @anhtriet1248 @cxsmie
Thank you for helping! All of your solutions work!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.