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:

`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`
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