- What do you want to achieve?
Well firstly, i have a module script with a index of 100 tables which contains 3 diffrent indexes for a randomies color
- What is the issue?
I can’t seem to figure out how i can find the table within the table, beacuse it always prints out as nil
I did try to search somewhere else but I could not find any helpfull articles
Module script
local Colors= {}
for Stage = 1, 100, 1 do
local a = {math.random(0,255), math.random(0,255), math.random(0,255)}
table.insert(Colors,a)
wait()
end
print(Colors)
return Colors
This prints out something like this for an example:
[1] = {
[1] = 21
[2] = 212
[3] = 92
}
The main script:
local Colors = require(script.ModuleScript)
local CollectionService = game:GetService("CollectionService")
local db = true
while wait(.1) do
local TaggedParts = CollectionService:GetTagged("TaggedParts")
for _, TaggedPart in ipairs(TaggedParts) do
local CurrentPart = TaggedPart
CurrentPart.Touched:Connect(function(hit)
if db == true then
local Stage = CurrentPart:FindFirstChild("Stage")
local HitStage = hit:FindFirstChild("Stage")
if hit.Name == "Part" then
if CurrentPart.Stage.Value == HitStage.Value then
local part = Instance.new("Part", workspace)
local StageVal = Instance.new("NumberValue", part)
StageVal.Name = "Stage"
part.Material = Enum.Material.SmoothPlastic
CollectionService:AddTag(part, "TaggedParts")
local Drag = Instance.new("DragDetector", part)
Drag.DragStyle = Enum.DragDetectorDragStyle.TranslateViewPlane
Drag.ResponseStyle = Enum.DragDetectorResponseStyle.Geometric
StageVal.Value = TaggedPart.Stage.Value + 1
local StageColor = Colors[StageVal]
**part.Color = Color3.fromRGB(StageColor[1],StageColor[2],StageColor[3])**
CurrentPart:Destroy()
hit:Destroy()
part.Position = CurrentPart.Position
db = false
wait(.2)
db = true
end
end
end
end)
end
end
The part which i set the part.Color i can’t figure it out