Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Comparing two NumberValues does not work, why?

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

2 comments

0

You have to compare their values, not the object itself. So, do this. script.Parent.Parent.ProcentValue.Value >= script.Parent.Parent.ProcentValue2.Value

0

Oh that's right, I always get stuck on the easy things, thanks.

1 answer

✓ Accepted answer

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)

2 comments

0

Thanks, too easy

0

Glad to help.

This discussion is preserved as it was. New answers, comments, and votes are closed.