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

the part color wont i get this error "attempt to index field '?' (a string value) "how do fix ?

i get this error Workspace.Script:15: attempt to index field '?' (a string value)

local part =  {"p","p2","p3","p4"
	



}

part.p = game.Workspace.Part
part.p2 = game.Workspace.Part2
part.p3 = game.Workspace.Part3
part.p4 = game.Workspace.Part4

while true do
	wait()
	part[math.random(1,4)].BrickColor = BrickColor.Random()
end

1 answer

I've answered this twice before, but this time I'm just going to give you the answer:

local p = workspace.p
local p2 = workspace.p2
local p3 = workspace.p3
local p4 = workspace.p4

local part = {p, p2, p3, p4}

while true do
	wait(1)
	part[math.random(1,4)].BrickColor = BrickColor.Random()
end

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