Having to use if statements even though their unnecessary

Hello! I’m learning Luau scripting for Roblox, but I ran into an issue. Whenever I write some code to change something like transparency, I need to use an if statement to do so. It’s not a huge deal, but it’s kind of annoying. An example of what I have to do is this:

local MyPart = game.Workspace.MyPart

if MyPart.Transparency == 0 then
    MyPart.Transparency = 0.5
end

when it should be this:

local MyPart = game.Workspace.MyPart

MyPart.Transparency = 0.5

See what I mean? The first code works, but the second doesn’t. I tried making a function and all that, but nothing has worked yet. I tried searching on youtube for some tutorials but i found nothing. I have the latest version of studio so it shouldn’t be that. Anyone else experiencing the same thing?

Answers are highly appreciated. Thanks!

local MyPart = game.Workspace.MyPart

MyPart.Transparency = 0
wait()
MyPart.Transparency = 0.5

does this work?

I’m not sure what’s wrong, since this code works just fine on my end. Can you show the explorer?

Yes, it does. But i know what my problem was. I misspelled it in the actual script.