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

How to make a model damage a player in 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)

你打错了。 script.Parent.Touched 是一个信号,您使用函数 Connect 连接到它,而不是 FindFirstChild:

script.Parent.Touched:Connect(function(hit)