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

question about reflectance with a script?

Asked by 3 years ago

if script.Parent.Reflectance == 0.65 then print("Reflectance") end

if i do that it wont detect anything, but only can detect if reflectance is set to 0 or 1,i need this for part of my gun system

1 answer

Log in to vote
0
Answered by
Vathriel 510 Moderation Voter
3 years ago
Edited 3 years ago

You're encountering a floating point error.

I'm not going to do the math behind it right now but you can essentially think of this instead as a margin of error problem.

Try this:

if math.abs(game.Workspace.Baseplate.Reflectance-0.65) < 0.01 then print("Reflectance") end

Here is a link to floating point error information:

Floating Point Arithmetic

Video of the Representation

Ad

Answer this question