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

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

Asked by 4 years ago
Edited 4 years ago

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:

01`local normalColor = {}
02    player.Humanoid.WalkSpeed = lightningMode.Settings.speed
03    game.ReplicatedStorage.Skills.Effects.LightningMode:Clone().Parent = player.HumanoidRootPart
04    for i,bodyPart in pairs(player:GetChildren()) do
05        if bodyPart:IsA("BasePart") and bodyPart.Name ~= "HumanoidRootPart" then
06            table.insert(normalColor,bodyPart.Color)
07            bodyPart.Color = Color3.new(0,0,255)
08            bodyPart.Transparency = .7
09        end
10    end
11    for i,v in pairs(normalColor) do
12        print(v)
13    end
14    wait(lightningMode.Settings.duration)
15    player.Humanoid.WalkSpeed = 16
View all 24 lines...
0
what line did you get the error in zadobyte 692 — 4y
0
I get the error in line 19 DeUltimate23 142 — 4y

1 answer

Log in to vote
0
Answered by
SirGamezy 186
4 years ago

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.

Ad

Answer this question