Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I write Color3 Value in the table?

Asked by 8 years ago

The tables :

ListOfSpells = {"avada kedavra","duro","expelliarmus"}
ColorsN = {"Lime green","Bright yellow","Bright red"}
ColorsNu = {Color3.new(0,170,0),Color3.new(255,255,255)}

The part of script that should get the values from the table:

for Number,inList in pairs(ListOfSpells) do
if SpellName == inList then 
Tool.Activated:wait()
 functions.CreateSpell(ColorsN[Number],ColorsNu[Number],SpellName,Player)
end 
end 

The CreateSpell is MainModule function

local functions = require(script.ModuleScript)

Everything works except of the ColorsNu values It should color PointLight to the ColorsNu[Number] value

1 answer

Log in to vote
0
Answered by
shayner32 478 Trusted Moderation Voter
8 years ago
Edited 8 years ago

First of all, instead of having three separate tables, why not just use one? Secondly, why store both BrickColor names and then Color3 values? Here's an easier implementation.

Tables

local spells = {
    { 
        ["name"] = "Avada Kedavra",
        ["color"] = "Lime green"
    },
    {
        ["name"] = "Duro",
        ["color"] = "Bright yellow"
    },
    { 
        ["name"] = "Avada Kedavra",
        ["color"] = "Bright red"
    }
}

The CreateSpell bit

for x,y in pairs(spells) do
    if SpellName == v["name"] then  -- Checks if SpellName is the same as the current spell we're on
        Tool.Activated:wait()
        functions.CreateSpell(BrickColor.new(v["color"]),SpellName,Player)
    end 
end 

You'll need to rewrite the CreateSpell function itself a bit to remove the 2nd Color3 argument, and instead make it so that it uses the BrickColor passed to it.

0
Thank You! Vinteriss 10 — 8y
0
No problem, mark my answer as correct if it worked for you. shayner32 478 — 8y
0
I'm trying but I don't know how to xd Vinteriss 10 — 8y
0
Should be an 'Accept answer' button or something along those lines on the right side of my answer shayner32 478 — 8y
View all comments (6 more)
0
I don't see it Vinteriss 10 — 8y
0
my dude, there should be like a green button or something on the right side of my answer near my name shayner32 478 — 8y
0
there is nothing like that I swear Vinteriss 10 — 8y
0
you're looking at this, correct? http://prntscr.com/d3uajv shayner32 478 — 8y
0
Yes Vinteriss 10 — 8y
Ad

Answer this question