我应该如何使此代码起作用?当我单击墙壁时,只有当他死了时,Judoon角色才能重新生成(重生)。[![Regenerate] [1]] [1]当我单击墙壁时,我的Judoon角色必须重新生成,但仅当他死了。
此外,我如何引入脚本Regen Button和Judoon模型是分开的,但是应该可以。如果将脚本Regen与Judoon文件夹分开放置到工作区中,它将无法正常工作。
local box = script.Parent
local debounce = false
-- DO NOT GROUP THIS WITH YOUR MODEL!
local everything = {Judoon}
local names = {Judoon}
local children = game.Workspace:children()
for i=1,#children do
if (children[i].Name == "Judoon") then -- Replace the name with your models's name.
table.insert(everything, children[i]:clone())
table.insert(names, children[i].Name)
end
end
function regen()
for i=1,#everything do
game.Workspace:findFirstChild(names[i]):remove() -- Dont mess with this stuff.
new_thing = everything[i]:clone()
new_thing.Parent = game.Workspace
new_thing:makeJoints()
end
end
function onClicked()
if Judoon:FindFirstChild("Judoon"):GetState() == Enum.HumanoidStateType.Dead then
regen()
end
end
wait(15)-- This is how long it takes untill the regen button will work again.
script.Parent.BrickColor = BrickColor.new(104)
debounce = false
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
--This regen button was made by andymewborn,hope you like(d) it!
[1]: https://i.stack.imgur.com/HhLo3.png
您可以执行类似的操作,如果人形生物死了,请重新生成。