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

Am I changing this Beam Color correctly?

It is not working for some reason? Please help if you can.

	if v:FindFirstChild("6") then
		for _, v2 in pairs(v:GetChildren()) do
			
			if v2:FindFirstChild("BeamOne") then
				v2.BeamOne.Color = ColorSequence.new(Color3.fromRGB(Data.SlashColor2.Value), Color3.fromRGB(Data.SlashColor2.Value))
			end	

			if v2:FindFirstChild("BeamTwo") then
				v2.BeamTwo.Color = ColorSequence.new(Color3.fromRGB(Data.SlashColor3.Value), Color3.fromRGB(Data.SlashColor3.Value))
			end

			if v2:FindFirstChild("BeamThree") then
				v2.BeamThree.Color = ColorSequence.new(Color3.fromRGB(Data.SlashColor4.Value), Color3.fromRGB(Data.SlashColor4.Value))
			end
		end			
	end

1 comment

0

Put prints all around the code and see/show what printed, are there any errors? We don't see what you see, v could not have 6 in it, v could not have any children, etc., you need to give us more info.

1 answer

✓ Accepted answer

try this:

local v = script.Parent
--// this Data table isnt needed since you have your own? its a way for me to debug the code
local Data = {
	SlashColor2 = {Value = Color3.fromRGB(0,255,255)},
	SlashColor3 = {Value = Color3.fromRGB(255,0,255)} ,
	SlashColor4 = {Value = Color3.fromRGB(255,168,64)}
}
if v:FindFirstChild("6") then
	local Six = v["6"] 
	if Six:FindFirstChild("BeamOne") then
		Six.BeamOne.Color = ColorSequence.new({
			-- this would normally be something like 
			--[[
				Key: 					 (Time to show color, The color to show )
				ColorSequenceKeypoint.new(0					,Color3.new(255,128,0),
				ColorSequenceKeypoint.new(0.5				,Color3.new(255,128,255),
				ColorSequenceKeypoint.new(1					,Color3.new(0,128,255)
				
				Also note you can have upto 15 color states any more than 15 and it will error
			]]
			ColorSequenceKeypoint.new(0,Data.SlashColor2.Value),
			ColorSequenceKeypoint.new(1,Data.SlashColor2.Value)
		})
	end 
	if Six:FindFirstChild("BeamTwo") then
		Six.BeamTwo.Color = ColorSequence.new({
			ColorSequenceKeypoint.new(0,Data.SlashColor3.Value),
			ColorSequenceKeypoint.new(1,Data.SlashColor3.Value)
		})
	end

	if Six:FindFirstChild("BeamThree") then
		Six.BeamThree.Color = ColorSequence.new({
				ColorSequenceKeypoint.new(0,Data.SlashColor4.Value), 
				ColorSequenceKeypoint.new(1,Data.SlashColor4.Value)
		})
	end
end

Hope this helps! :)

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