使用another question中的儿童监控脚本@Kylaaa,我花了几个小时在这上面,改变了核心功能,从修复和消失的砖块到当玩家“穿过树叶”时播放父母的声音。我一直在研究这个问题的各个方面('IsA','TouchInterest','If...then',类,运算符等),并做了各种事情,例如修改我的脚本以查看被触摸对象的名称,而不是它们的类,但我没有幸运地播放声音。

-- create a helper function to access the brick and the thing that touched it
function OnTouched(thing)
local active = false --start with this debounce variable off so that the function will run the first time
return function(target) --provides actual target of the event
if active then return end -- do not do the animation again if it has already started
local player=thing.Parent:findFirstChild("Humanoid") --determine if it's humanoid
if player then --if it is, then
active = true --toggle to prevent function from running again simultaneously
script.Parent:play() --play rustling leaves sound
wait(1)
active = false -- reset so function can be used again
end --end of if statement
end
end
-- loop over the children and connect touch events
local bricks = script:GetChildren()
for i, brick in ipairs(bricks) do
if brick:IsA("Part") then
local onTouchedFunc = OnTouched(brick)
brick.Touched:Connect(onTouchedFunc)
end
end这是我想添加沙沙声的落叶层的一张照片。我在左边的藤条上也有同样的问题。

葡萄藤:

所有的叶子都是'MeshParts‘,里面有'SurfaceAppearance’,并且是锚定的和CanTouch,但不是CanCollide。我试着打开CanCollide,但没用。
密集叶面片属性:

表面外观特性:

我试过"if brick:IsA("Model“或"MeshPart") then”和"if brick.Name=="Dense Leaf patch“或"SurfaceAppearance”或"DenseLeafPatch“then”,但这两种方法都不起作用。
然后我注意到TouchInterest不是由Roblox生成的,我知道你既不能复制也不能复制TouchInterests在你需要的地方使用(根据DevForum中的一条消息,它们不是为开发人员准备的)。
我最初在单独的模型中有1-3个叶子'MeshPart's,但后来做了一个单独的,不可见的部分(名称: TouchInterest),CanTouch而不是CanCollide,它大到足以覆盖几乎所有实例的物理区域,并将所有的MeshParts放到那个部分中。然后,我修改了脚本,只查找‘部分’。结果,在运行时生成了一个TouchInterest。

这是“叶子”组中涉及的所有内容,包括声音,然后是脚本,包含部分,然后是里面的所有叶子,作为脚本的孩子。

声音的属性:

输出中没有与此相关的错误。
我觉得有些简单的东西我不明白。我需要几个小的部分(而不是一个大的部分)来包含树叶组吗?请帮帮我!
发布于 2021-10-29 12:37:20
我发现了问题所在。
“。
https://stackoverflow.com/questions/69746061
复制相似问题