Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Comparing two NumberValues does not work, why?

Asked by
xsodar 19
4 years ago
script.Parent.Touched:Connect(function(hit)
    if script.Parent.Parent.ProcentValue >= script.Parent.Parent.ProcentValue2 then
    script.Parent.Parent.TouchValue.Value = 100 
    end     
end)

New to scripting, why can I not compare two NumberValues? Is there any way I can get around this? The script is supposed to compare two NumberValues so another value gets the value 100.

Thanks, Xsodar

0
You have to compare their values, not the object itself. So, do this. script.Parent.Parent.ProcentValue.Value >= script.Parent.Parent.ProcentValue2.Value killerbrenden 1537 — 4y
0
Oh that's right, I always get stuck on the easy things, thanks. xsodar 19 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

As stated by killerbrenden in the comments, you need to compare their values not the object itself. A simple fix to this would be adding .Value in both ProcentValue and ProcentValue2. It would look like this.

script.Parent.Touched:Connect(function(hit)
    if script.Parent.Parent.ProcentValue.Value >= script.Parent.Parent.ProcentValue2.Value then -- As you can tell, we added .Value to both of these here to compare their values rather than the actual object itself.
    script.Parent.Parent.TouchValue.Value = 100 
    end     
end)
0
Thanks, too easy xsodar 19 — 4y
0
Glad to help. JoyfulPhoenix 139 — 4y
Ad

Answer this question