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

error attempt to call field 'fromRBG' (a nil value)?

Asked by 6 years ago
    Tiles = Instance.new("Model")
    Tiles.Parent = game.Workspace
    Tiles.Name = "Tiles"
    Tiles.Archivable = true
    brickArray = {}
    red = 30

for i=1,30, 1 do
    Brick = Instance.new("Part")
    Brick.Name = "Brick" .. i
    Name = Brick.Name
    table.insert(brickArray, Brick.Name)
    Brick.Parent = game.workspace.Tiles
    Brick.Anchored = true
    Brick.Size = Brick.Size + Vector3.new(20,0,22)
    Brick.Color = Color3.fromRGB(0,0,0)
    Brick.Locked = false
    if i < 6 then
        Brick.CFrame = CFrame.new(24*i,0,0)
        elseif i < 12 then
        Brick.CFrame = CFrame.new(24*(i-6),0,24)
        elseif i < 18 then
        Brick.CFrame = CFrame.new(24*(i-12),0,48)
        elseif i < 24 then
        Brick.CFrame = CFrame.new(24*(i-18),0,72)
        elseif i < 30 then
        Brick.CFrame = CFrame.new(24*(i-24),0,96)
    end
end

    Brick.Touched:Connect(function(hit)
        Brick.Color = Color3.fromRBG(10, 0, 0)
    end)

This script keeps returning the error attempt to call field 'fromRBG' (a nil value). This doesn't make sense to me because I've used this function just a few lines above the second time and it works fine. Why is this throwing me an error?

0
That's really weird. It should be working. spartanlord456 19 — 6y

1 answer

Log in to vote
1
Answered by
BloxRoxe 109
6 years ago
Edited 6 years ago

You used Color3.fromRBG instead of Color3.fromRGB

you just switched the order of the letters. It has to be in the order of Red, Green, Blue.

0
I am disappointed in myself XD GarryGecko99 30 — 6y
0
Do you happen to know why it isn't working though? It's a grid of 30 tiles, but when i touch any tile, only the 30th tile actually changes color GarryGecko99 30 — 6y
Ad

Answer this question