Lua 在roblox工作室有没有办法让NPC重生?
所以,我在roblox工作室编写这个格斗游戏。现在我已经制作了一个NPC,但我想让它在死后几秒钟能够重生,但我不知道如何检查NPC是否死亡,或者如何重生一个NPC并使其重新连接到身体部位Lua 在roblox工作室有没有办法让NPC重生?,lua,roblox,Lua,Roblox,所以,我在roblox工作室编写这个格斗游戏。现在我已经制作了一个NPC,但我想让它在死后几秒钟能够重生,但我不知道如何检查NPC是否死亡,或者如何重生一个NPC并使其重新连接到身体部位 谢谢你,我希望你能帮上忙。你可以从NPC的类人属性的健康检查NPC的健康状况,看看它是活的还是死的 game.workspace.<NPC>.Humanoid.Health 最后,在while循环中包装这一切,这样它就可以持续检查NPC的健康状况 while wait() do if game
谢谢你,我希望你能帮上忙。你可以从NPC的
类人
属性的健康
检查NPC的健康状况,看看它是活的还是死的
game.workspace.<NPC>.Humanoid.Health
最后,在while
循环中包装这一切,这样它就可以持续检查NPC的健康状况
while wait() do
if game.workspace.<NPC>.Humanoid.Health <= 0 then
wait(2) -- If you want to wait before the NPC respwns, change '2' for the amount of seconds you want to wait
game.ReplicatedStorage.<NPC>:Clone().Parent = game.workspace
end
end
while wait()执行
如果游戏.工作区..类人.健康这是一个很好的答案!作为一种优化,在生成NPC后,您可以收听音频,而不是使用while循环检查NPC的运行状况。然后在事件处理程序中,您可以稍等片刻,然后生成一个新的NPC。
if game.workspace.<NPC>.Humanoid.Health <= 0 then
wait(2) -- If you want to wait before the NPC respwns, change '2' for the amount of seconds you want to wait
game.ReplicatedStorage.<NPC>:Clone().Parent = game.workspace
end
while wait() do
if game.workspace.<NPC>.Humanoid.Health <= 0 then
wait(2) -- If you want to wait before the NPC respwns, change '2' for the amount of seconds you want to wait
game.ReplicatedStorage.<NPC>:Clone().Parent = game.workspace
end
end