【发布时间】:2018-06-14 18:13:09
【问题描述】:
我正在尝试制作一个带有掉落块级别的 obby,并且砖块掉落得很好,但我希望它们在碰到某个块时消失,这样它们就不会看起来很乱。有什么帮助吗?
【问题讨论】:
我正在尝试制作一个带有掉落块级别的 obby,并且砖块掉落得很好,但我希望它们在碰到某个块时消失,这样它们就不会看起来很乱。有什么帮助吗?
【问题讨论】:
假设每个掉落的部分都是一个新的部分,你可以简单地在被角色触摸时破坏该部分。
script.Parent.Touched:connect(function(hit)
if hit:FindFirstChild('Humanoid') then -- Check if it is a character that touched the part
script.Parent:Destroy()
end
end
【讨论】:
接受的答案不再起作用,这对我有用:
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChildWhichIsA('Humanoid') then -- Check if it is a character that touched the part
script.Parent:Destroy()
end
end
)
【讨论】:
我想我知道出了什么问题。这是我的代码。
local block = script.Parent
local debounce = true
block.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChildWhichIsA('Humanoid')
if humanoid and debounce == true then
debounce = false
block.Transparency = 0.5
wait(1)
block.Transparency = 1
block.CanCollide = false
wait(3)
block.Transparency = 0
block.CanCollide = true
debounce = true
end
end)
制作一个零件并将其命名为块,然后使用上面的代码插入一个脚本,它将完美运行。 (您可以通过多次复制粘贴“wait(1)”和“block transparent”并缩小数字来使其更流畅。示例:
local block = script.Parent
local debounce = true
block.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChildWhichIsA('Humanoid')
if humanoid and debounce == true then
debounce = false
block.Transparency = 0.1
wait(0.2)
block.Transparency = 0.2
block.CanCollide = true
wait(0.2)
block.Transparency = 0.3
block.CanCollide = true
wait(0.2)
block.Transparency = 0.4
block.CanCollide = true
wait(0.2)
block.Transparency = 0.5
block.CanCollide = true
wait(0.2)
block.Transparency = 0.6
block.CanCollide = true
wait(0.2)
block.Transparency = 0.7
block.CanCollide = false
wait(0.2)
block.Transparency = 0.8
block.CanCollide = false
wait(0.2)
block.Transparency = 0.9
block.CanCollide = false
wait(0.2)
block.Transparency = 1
block.CanCollide = false
wait(3)
block.Transparency = 0
block.CanCollide = true
debounce = true
请注意我如何将 CanCollide 值设置为 true 直到某个点。这很重要,因为:一旦你触摸它,方块就会消失,没有给玩家跳跃的机会。相反,它消失得足够晚,让玩家有时间做出反应。
【讨论】: