【发布时间】:2019-09-12 04:14:36
【问题描述】:
所以,我创建了一个按钮脚本,当单击时,如果某个条件为真,它会找到不同模型的所有孩子,但是当我找到孩子时,它给我一个错误,说“Obj 不是模型的有效成员”,然后什么都不做
这是我的代码:
script.Parent.Touched:Connect(function(hit)
if(hit.Name == "RightFoot" or hit.Name == "LeftFoot") then
if(script.Parent.Color == Color3.fromRGB(0, 255, 0)) then
--This line is where im getting problems, when i do this :GetChildren
for _, object in pairs(script.Parent.Parent.Obj:GetChildren()) do
if(object:IsA("BasePart")) then
object.CanCollide = true
object.Transparency = 0
end
end
end
end
end)
【问题讨论】:
-
尝试 :waitforchild 而不是 obj 并在引号中包含 obj,如下所示:script.Parent.Parent:WaitForChild("Obj"):GetChildren()) 做