如何在Lua中让模型对玩家造成伤害

我想知道如何让模型对玩家造成伤害。我尝试了这个脚本,但它不起作用。我该怎么修复它?

local Debounce = false
script.Parent.Touched:FindFirstChild(function(hit)
   if hit.Parent:FindFirstChild("Humanoid") and Debounce == false then
      Debounce = true
      hit.Parent.Humanoid:TakeDamage(10)
      wait(0)
      Debounce = false
      end
   end)
点赞
用户2860267
用户2860267

你打错字了。script.Parent.Touched 是一个信号(signal),你需要使用函数 Connect 来连接它,而不是 FindFirstChild

script.Parent.Touched:Connect(function(hit)
2020-11-11 20:15:00