Why i am kept getting this error from client?

Im trying achive color changing from client and here the problems from below.

Local Script


script.Parent.MouseButton1Click:Connect(function()

   local plr = game.Players.LocalPlayer.PlayerGui.MS.a

   for i,v in pairs(script.Parent.Parent.a:GetDescendants(plr)) do
   local ic = i
   for d = 1, #ic do
   if d:IsA("Model") then
   local model = d
   for c = 1, #model do
	local child = model[c]
	if child:IsA("BasePart") then
		child = script.Parent.Parent.Red.Value -- Color3Value
		print("Colour has change")
	end
end

end
end
end
end)

Output Error

23:27:07.039 - Players.Joshua7ninjaX.PlayerGui.MS.TextButton.LocalScript:7: attempt to get length of a number value

Property

Image from Gyazo

I cant seem to find any solution? Can you help?

2 Likes

You are attempting to set “child”, a BasePart, as a Color3 value within your Color3 Value, although, I’m slightly confused as to what you’re trying to do. Are you trying to set the Color3 value of “child” to the color in your Value?

3 Likes

Yep that correct, Color3.Value = 0,0,0 :arrow_right: for BasePart

2 Likes

Check line 7, the value there is not a table and is instead a number. Make 100% sure that you are assigning it the correct value. In this case, for i, v in next...i will be the index and v will be the object/value.

2 Likes

@Joshua7ninjaX

You should try setting the Color value of the BasePart to the Color3 value inside of your Value.

script.Parent.Parent.Red.Value = child.Color
1 Like

Thank for your support. :clap:

1 Like

From number 7 i kept getting this, 'attempt to get length of a number value ?

   for i,v in pairs(script.Parent.Parent.a:GetDescendants(plr)) do
   local ic = i
   for d = 1, #ic do --

00:03:49.905 - Players.Joshua7ninjaX.PlayerGui.MS.TextButton.LocalScript:7: attempt to get length of a number value

It come from the property Image i posted. Model ain’t value, there is more than 1 an inside parent Model ‘a

i is the index of the item in the array, not the item itself

Your right, so i adapt this and just one error for ‘IsA


script.Parent.MouseButton1Click:Connect(function()

   --local plr = game.Players.LocalPlayer.PlayerGui.MS.a
   local plr
   for i,v in pairs(script.Parent.Parent.a:GetDescendants(plr)) do
   local ic = plr
   if ic:IsA("Model") then
   local model = ic
   for c = 1, #model do
	local child = model[c]
	if child:IsA("BasePart") then
	script.Parent.Parent.Red.Value = child.Color -- Color3Value
		print("Colour has change")
	end
end

end
end
end)

00:20:42.381 - Players.Joshua7ninjaX.PlayerGui.MS.TextButton.LocalScript:7: attempt to index nil with ‘IsA’

1 Like

use v instead of ic or plr as it will be the current item in iteration

It been solve i found the mistake i did, when u mention this

1 Like

because i didn’t understand for i,v next… i just picked it up and move on.