LocalTransparencyModifier not working as expected

I have been trying to make a first person viewmodel. However, when I set the part.Transparency = 1 and part.LocalTransparencyModifier = -0.5, the client-side transparency remains as 1.

The devhub provides this script to show us how the modifier works:

local clientTransparency = part.Transparency + (1 * part.localTransparencyModifier)

So, according to this script, my idea should work.
(by the way, when I set the transparency to 0, and modifier to 0.5, it works as expected, client-side transparency is 0.5)

The code is just as simple as I explained
obraz

Besides, how does this equation work (the one highlighted with red)?
0.5 + 1*0.5 should be equal to 1??

“Besides, how does this equation work (the one highlighted with red)?
0.5 + 1*0.5 should be equal to 1??”

You’re right it equals 1 but I think luau doesn’t use the priority of operations rule meaning that first 0.5 + 1 is made first so 1.5 * 0.5 = 0.75 I think maybe it affects your script.

EDIT: I tested in my test game if what I said is true but luau uses the priority of operations this came out as 1

print(0.5 + 1 * 0.5)

that means the devhub haves this error where someone didn’t knew about priority of operations it’s not your fault.

I just tested it for transparency = 0.5 and localtransparency = 0.5 and it actually makes the parts client side transparency 0.75

So I’m guessing the provided equation is wrong, or I just don’t get something

It’s actually equal 0.5 I think since the first number is the transparency based on these images

I cannot give further help I’m also stuck

I believe what it is doing is it takes the parts transparency, subtracts that from 1, and the fraction that is left over is multiplied by the localtransparencymodifier. So formula wise it would be:

local clientTransparency = part.Transparency + (1-part.Transparency) * part.localTransparencyModifier
1 Like

So you’re saying one can never change the client transparency if the server transparency is 1?

Well, I forgot I can just clone the viewmodel locally so that other players can’t see it, which is even better than setting the local transparency.

Thank you for the reply though, it made me think of another solution to my problem. :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.