当たるとしぬ部品・ブロックを作る方法【Roblox Studio】

Roblox Studioで、以下のスクリプトを追加します。

function killHumanoid(part)
	local humanoid = part.Parent:findFirstChild("Humanoid")
	if humanoid ~= nil then
		humanoid.Health = 0
	end
end

script.Parent.Touched:connect(killHumanoid)

FindFirstChildOfClassを使用してHumanoidクラスで判別したい場合:

function killHumanoid(part)
	local humanoid = part.Parent:FindFirstChildOfClass("Humanoid")
	if humanoid ~= nil then
		humanoid.Health = 0
	end
end

script.Parent.Touched:connect(killHumanoid)

コメントを残す

メールアドレスが公開されることはありません。