NumberValue can't be checked?

So i’m trying to make a stamina system using number values. The number values are working great! They deplete as they should. But this one stinking line of code meets me with an error message!

if char.Stamina.Value > 0 then 

Help would be appreciated.

Can you show what other instances are under the character? The issue might be caused by having multiple instances named Stamina under the character and that it is indexing the script instead of the value.


here ya go! It may have to do with the boolvalue inside but idk

instead do
if char.Stamina.Value == “your max stamina number” then
I also do have a stamina system using number values and mines work perfectly.

Rename the Stamina NumberValue to StaminaValue. Then just change the name of the value in the script

Alright. I’ll try that! Thanks

1 Like

The issue is that you have multiple instances under your character named Stamina and Roblox cannot accurately predict which value you are trying to access. You can fix this by renaming one of the instances or by using FindFirstChildOfClass("NumberValue") to get the stamina value (but this wouldn’t work if you have multiple number values).

Thanks! it seemed that simply renaming it worked though (;

Thanks to everyone who helped me

This issue occurred because you had 2 instances which shared the same name in this case that name was “Stamina” when creating models it is very important to ensure that child instances which will be referenced in scripts are given unique names that way they can uniquely be referenced by the script without any collision issues.

I think you should give @bmcqqq the solution mark. His post has very good explanation and details. It would help you and others understand what is the issue when encountering this problem.

2 Likes