Yeah, descendants that dont have a color to them are not expected to be edited in the first place LOL
in a way? it literally silents the error that MIGHT be the issue why its not working
The first line is always executed so no
descendant.Color = typeof(descendant.Color) == "ColorSequence" and ColorSequence.new(ColorValue) or ColorValue
descendant.Brightness = 0
descendant.LightEmission = 0
descendant.Transparency = G.MultiplyNumberSequence(descendant.Transparency, 0.9)
descendant.Size =
typeof(descendant.Size) == "NumberSequence"
and G.MultiplyNumberSequence(descendant.Size, sizeMultiplier)
or descendant.Size * sizeMultiplier
descendant.Rate *= sizeMultiplier
descendant.Speed = NumberRange.new(descendant.Speed.Min * sizeMultiplier, descendant.Speed.Max * sizeMultiplier)
descendant.Lifetime = NumberRange.new(descendant.Lifetime.Min * sizeMultiplier, descendant.Lifetime.Max * sizeMultiplier)
A bit edited but can you please send the entire code? I don’t know what “ColorValue” is.
local ColorValue = SpellValue.ColorValue.Value
local LightEmission = 0.75
if
(ColorValue.R * 255) <= 110
and (ColorValue.G * 255) <= 110
and (ColorValue.B * 255) <= 110
then
LightEmission = 0.25
end
local colorSequence = SpellValue:FindFirstChild("ColorSequence")
colorSequence = colorSequence and colorSequence.Color or ColorSequence.new(ColorValue)
the only reason you could use a pcall in here that is reasonable is to check if the descendant has the property, instead of supressing the whole body
local hasPropery = pcall(function()
return descendant["Color"]
end)
Hm, I see now why you have used pcall
. However, I still consider this code bad practice because it wasn’t obvious what the intention behind using it was. Even if you think it is obvious, you are still asking help from people online, and making your code easier to understand will make it easier to get help from other people and for other people to help you.
Additionally, because @awry_y explained the issue first, you should mark their reply as the “Solution” for other readers of this thread:
You seem to be missing the point here, I’m not looking for best practice, I know what’s the best practice and I chose readability over slight performance diff
doesn’t matter if its executed lol? execution doesnt always mean success, especially in pcall, literally thats what pcall is for, you are still not understanding what that is
then don’t expect much if best practice is your last priority
Ok so let’s say you’re right and it errors, what makes it error then? ColorSequence is set as expected no?
then you fix the error? what kind of stupid question is that
Which is? What’s the error in the first line?
are you actually ok bro?
Ok so let’s say you’re right and it errors
do i look like a compiler to you?
You suggest there’s an error at the first line but you have nothing to base that assumption on. The only reason you’re suggesting this is to make a case for your pcall argument which is irrelevant to this discussion
Just to make sure, you are wrapping it in a pcall
because there are some descendants of your Model that do not have a Color
/ Brightness
/ Rate
/ Speed
/ Size
property, right?
which is why I mentioned this to him if he really wants to use pcall
says the guy who made this post in the first place cause of these reasons:
- knows nothing about best practice.
- can’t script.
- can’t use common sense.
Yeah it’s structured in a specific way so what I need set is properly set
Can’t script, talk to me when you have made 2 successful games like me, you’ve got nothing to show for your bold talk mr pcall, bro comments on script support posts and does nothing but help which is the purpose of these posts, you couldn’t help anyone even if your life was on the line you silly incompetent guy