使用`getchildren()`获取点击事件。

huangapple go评论54阅读模式
英文:

Getting on click using getchildren()

问题

我有一个在Roblox Studio中的区域,上面有从0到9的按钮编号,我想获取该文件夹中的所有子项,并获取它们所有的点击检测器,但我不知道该如何做。请帮忙,谢谢。

已成功获取子项,但未成功获取点击检测器。

英文:

I have an area which has button numbers from 0 to 9 on roblox studio and I want to get all the children from that folder and also get the clickdetector for all of them but I dont know how. Please help thank you.

Managed to get the children but didnt manage to get the click detector

答案1

得分: 1

我假设您也想为所有按钮获取点击检测器,所以这里是代码:

local folder = --引用
local t = {}

for i,v in pairs (folder:GetChildren()) do
  if v:FindFirstChild("ClickDetector") then
      table.insert(t,v)
  end
end

--现在您可以做您想做的任何操作,因为您已经拥有了您想要的对象/按钮
英文:

I assume you also want to get the click detector for all of the buttons, so here you go.

local folder = --reference
local t = {}

for i,v in pairs (folder:GetChildren()) do
  if v:FindFirstChild("ClickDetector") then
      table.insert(t,v)
  end
end

--do whatever you want next now because you have the objects/buttons you want

huangapple
  • 本文由 发表于 2023年5月7日 00:13:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/76189912.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定