if mainColor = "Blue" then
color1 = Color3.fromRGB(15, 127, 254)
color2 = Color3.fromRGB(255, 255, 255)
trail.Color = ColorSequence.new(color1, color2)
I used something like that but Idk if it is okay to use this because There is like 8-9 of them and I don’t want to use that much code space and make server script busy is there any easier way to do that?
for _,i in ipairs(toolConfig) do -- ToolConfig is the Module that has MainColor variable
if i.MainColor == "Blue" then
color1 = Color3.fromRGB(15, 127, 254)
color2 = Color3.fromRGB(255, 255, 255)
end
end
here is some details if you need
script is parented to a tool
attachments and trail are child of meshpart which is a child of that tool
I tried using this but even the tool I am equipped’s MainColor value is “Purple” trail shows the “Red” s color
for _,i in ipairs(toolConfig) do
if i.MainColor == "Purple" then
color1 = i.Color1
color2 = i.Color2
elseif i.MainColor == "Red" then
color1 = i.Color1
color2 = i.Color2
end
end
trail.Color = ColorSequence.new(color1, color2)
I got the issue There is Yellow Value and because of elseif it doesn’t care about previous if statements and shows the yellow. But like I said I don’t know how to fix it
try to remove the elseif stuff
just make all colors have a separate if statement
if i.MainColor == "Purple" then
color1 = i.Color1
color2 = i.Color2
end
if i.MainColor == "Red" then
color1 = i.Color1
color2 = i.Color2
end
if i.MainColor == "Yellow" then
color1 = i.Color1
color2 = i.Color2
end
I think Problem is caused because of ipairs not with if Statements or elseif’s
for _,i in ipairs(toolConfig) do
if i.MainColor == "Purple" then
color1 = i.Color1
color2 = i.Color2
end
end
for _,i in ipairs(toolConfig) do
if i.MainColor == "Red" then
color1 = i.Color1
color2 = i.Color2
end
end
trail.Color = ColorSequence.new(color1, color2)
for _,i in pairs(toolConfig) do
if i.MainColor == "Purple" then
color1 = i.Color1
color2 = i.Color2
end
if i.MainColor == "Red" then
color1 = i.Color1
color2 = i.Color2
end
end
trail.Color = ColorSequence.new(color1, color2)
combine the if statement into 1 loop and change it too just pairs like this (tell me if it works)
for _,i in pairs(toolConfig) do
if i.MainColor == "Purple" then
color1 = i.Color1
color2 = i.Color2
print(i.Color1)
print(i.Color2)
end
if i.MainColor == "Red" then
color1 = i.Color1
color2 = i.Color2
print(i.Color1)
print(i.Color2)
end
end
trail.Color = ColorSequence.new(color1, color2)
print out the i.Color1 and 2, check if the colors are purple
color’s are printed different but you are not understanding the problem
Since there is a “Red” value in Tool Module No matter what happens it will show the red is color
If I change the red with SomethingLike “KomodaDragon” it will Show purple color because there is no “KomodaDragon” in the module and If I change places of Red and Purple it will show purple trail because of order.
I want to take MainColor of my equipped Tool
and if That tool’s value equals to purple, it should show purple color
But the thing ipairs do is checks the whole module and looks for the MainColor value inside that module
you need to add a string value in each tool that has the color name.
for example, the tool that needs to be purple will have a string value named “toolColor” and the value of that will be “Purple”
local toolValue = tool.toolColor.Value
for _,i in ipairs(toolConfig) do
if i.MainColor == toolValue then
color1 = i.Color1
color2 = i.Color2
end
end
trail.Color = ColorSequence.new(color1, color2)
There should be a easier way Because tracking every tool’s toolColor.Value by scripts is not a good way like by this way you have to Change every toolColor.Value manually and if there is 100 tools, welp not a good way.