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

Invalid Argument #3 (Color3 expected, got nil)? (SOLVED)

So I was creating a mode which speeds you up for a certain amount of time, and while it is doing that I changed the player's color3 values and stored the previous color in a table, but whenever i try to call the table and set the color back to it's previous color I get this error saying ("Color3 expected got nil")

Here is the code if you happen to take a look at this:

`local normalColor = {}
	player.Humanoid.WalkSpeed = lightningMode.Settings.speed
	game.ReplicatedStorage.Skills.Effects.LightningMode:Clone().Parent = player.HumanoidRootPart
	for i,bodyPart in pairs(player:GetChildren()) do
		if bodyPart:IsA("BasePart") and bodyPart.Name ~= "HumanoidRootPart" then
			table.insert(normalColor,bodyPart.Color)
			bodyPart.Color = Color3.new(0,0,255)
			bodyPart.Transparency = .7
		end
	end
	for i,v in pairs(normalColor) do
		print(v)
	end
	wait(lightningMode.Settings.duration)
	player.Humanoid.WalkSpeed = 16
	for bodyPartIndex,bodyPart in pairs(player:GetChildren()) do
		if bodyPart:IsA("BasePart") and bodyPart.Name ~= "HumanoidRootPart" then
			print(bodyPartIndex)
			bodyPart.Color = normalColor[bodyPartIndex]
			bodyPart.Transparency = 0
		end
	end
	player.HumanoidRootPart:FindFirstChildOfClass("ParticleEmitter"):Destroy()
end`

2 comments

0

what line did you get the error in

0

I get the error in line 19

1 answer

Your normalColor variable is table, with nothing in it. So, in line 19 of your script, you entered a nil value because there is no value in the table with the position of the number variable bodyPartIndex.

A possible solution would be to add Color3 values into the table.

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