Attempt to index nil with 'Color' error, not sure how to fix

Hey, I’m currently trying to fix an error a former scripter of a game made. It is spamming this error, even though everything is fine. The script is dedicated to a dance floor.
Code:

game.ReplicatedStorage.Copy.OnClientEvent:Connect(function()
	local va = game.ReplicatedStorage:WaitForChild("df", 0.5)
	if va then
		local v = va:Clone()
		v.Parent = script
		for i,v2 in pairs(v:GetChildren()) do
			local vaa = workspace.df:FindFirstChild(v2.Name)
			if vaa.Color ~= v2.Value then
				vaa.Color = v2.Value
			end
		end
		v:Destroy()
	end
end)

Error: image

Any help is appreciated, thanks!

If you need more information, please let me know.

why are you using OnClientEvent?

local vaa = workspace.df:FindFirstChild(v2.Name)

Whatever v2.Name is, it isn’t being found in workspace. You got a nil value. The point of df:FindFirstChild(v2.Name) is to see if that child first exists so you should be expecting a nil value anyways.

You could do this if you can’t find the child;

if vaa and vaa.Color ~= v2.Value then
    vaa.Color = v2.Value
end
1 Like

The script is a local script. You can see it named as one in the error.

why is he using local script for a dance floor?

I’m not sure myself why they did it, but I feel like it has some reason in it lol.