Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I write Color3 Value in the table?

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

✓ Accepted answer

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.

10 comments

0

Thank You!

0

No problem, mark my answer as correct if it worked for you.

0

I'm trying but I don't know how to xd

0

Should be an 'Accept answer' button or something along those lines on the right side of my answer

0

I don't see it

0

my dude, there should be like a green button or something on the right side of my answer near my name

0

there is nothing like that I swear

0

you're looking at this, correct? http://prntscr.com/d3uajv

0

Yes

This discussion is preserved as it was. New answers, comments, and votes are closed.