How would I decide what value to assign to a variable in one line?

How would you do something like


in lua?

I want to keep the script to be nice and clean, so I want to keep this in one line.
What I’m trying to do is, if “Smooth?” is true, to set _smooth (variable) to Enum.EasingStyle.Sine and If it isn’t, set it to Enum.EasingStyle.Linear.

I’ve tried to do this before, but I always got an error.

Do any of you know how to do this?

Remove the end, Luau’s ternary operator is if condition then true_value else false_value, of course you also have elseifs though you don’t need it in your case

This condition is called ‘Ternary’.
Maybe This Thread would help.

I suggest not working with ternary. It can return issues if something is false/nil.

That’s if you use and or, aka the old method, the new method roblox made prevents that I believe

Oh, nice to know.

Honestly, I think he should just do -

if config["Smooth?"].Value then
   
else

end

It’s personal preference, if it’s something simple as you’ve shown here, I would personally one line it, though some people would prefer it like that for their own reasons, both solutions give the same outcome so there’s nothing wrong with using one or the other unless it kills readability