My code is hooked up to a button that's supposed to change a part's color when clicked. But when its clicked, it just keeps giving me the error "attempt to call a table value". I've even tried the code by itself, and it works perfectly. So I don't really understand what's going on.
local ClickDetector = script.Parent:FindFirstChild("ClickDetector")
function OnClick()
for i,v in pairs(workspace.Baseplate:GetChildren()) do
if v:IsA("Part") and v.Name == "Door" then
v.BrickColor = BrickColor.new("Medium stone grey")
end
end
end
ClickDetector.MouseClick:Connect(OnClick)

2 comments
I took your script and placed it in a test baseplate and it worked fine without any errors. its probably something before the script you gave that caused the issue
No. That’s literally all there is