I was reading a wall climbing script.And I found this:
function down(KEY) return uis:IsKeyDown(Enum.KeyCode[KEY]) end
local sideDirection = rootpart.CFrame.RightVector*(down("D") and -2 or 2)
the down function returns a bool value but what does the 2nd line do. exactly.? im not understanding it. Pls explain.
1 Like
Basically what it does is that it multiplies the RightVector of the HumanoidRootPart, assuming rootpart
contains that by either -2 or 2, depending on the result of that operator
down("D") and -2 or 2
Basically means, if the function returns true
, multiply by -2, otherwise, if it returned false
multiply by 2
Or in context terms, if you’re holding down D, it’ll multiply the RightVector by -2, and if you are not, it multiplies it by 2
4 Likes