0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Roblox Studioで「プレイヤーが触れたら爆発して消える壁」を作る超簡単スクリプトです。わずか60秒で実装できるので、初心者にもおすすめです!


🎬 実際の動作を見たい?


🧱 Step 1: パーツを設置しよう

  1. ワークスペースに「Part」を1つ置きます。
  2. 名前を ExplodableWall に変更しておくと管理しやすいです。

🧠 Step 2: スクリプトを追加しよう

以下のスクリプトを ServerScriptService内にScriptとして挿入し、コピペしてください:

image.png

-- 💥 プレイヤーの腕や頭で触れたものを爆破&削除するスクリプト
-- 爆発は演出のみでダメージなし!

-- チェック対象のパーツ名(R15アバター用)
local breakParts = {
	"LeftHand",     -- 左手
	"RightHand",    -- 右手
	"Head"          -- 頭
}

-- プレイヤーがゲームに参加したときの処理
game.Players.PlayerAdded:Connect(function(player)
	-- キャラクター(アバター)がスポーンしたときの処理
	player.CharacterAdded:Connect(function(character)

		-- 指定した各パーツ(手や頭)について処理
		for _, partName in ipairs(breakParts) do
			local part = character:FindFirstChild(partName)

			-- パーツが見つかり、かつ物理オブジェクト(BasePart)だった場合
			if part and part:IsA("BasePart") then

				-- そのパーツが何かに触れたときの処理
				part.Touched:Connect(function(hit)

					-- 自分自身のキャラのパーツに触れた場合は無視する
					if not hit:IsDescendantOf(character) then

						-- 爆発エフェクトの作成(演出用・ノーダメージ)
						local explosion = Instance.new("Explosion")
						explosion.Position = hit.Position          -- 爆発位置:触れた場所
						explosion.BlastRadius = 5                  -- 爆発の見た目の範囲
						explosion.BlastPressure = 0                -- 吹き飛びやダメージなし
						explosion.DestroyJointRadiusPercent = 0   -- 接続されたパーツも壊さない
						explosion.Parent = workspace               -- ワークスペースに表示!

						-- 触れたオブジェクトを削除!
						hit:Destroy()
					end
				end)
			end
		end
	end)
end)


💡 解説(ざっくり)

プレイヤーの手や頭が他の物体に触れたときに、Touched イベントを検知します

触れたパーツがプレイヤー自身の体の一部ではないことを確認します

Robloxの爆発エフェクト(※ダメージなし)を発生させます

最後に、hit:Destroy() を使ってそのパーツを削除します


✅ おすすめの応用アイデア

隠し通路のギミックに!

敵キャラに触れると自爆させる罠にも応用可能!


🚀 まとめ

Robloxの物理エンジンを活用すれば、たった数行でこんな楽しい爆発ギミックが作れます。ぜひ自分のゲームにも取り入れてみてください!


👾 他の60秒シリーズも公開中!

気に入ったらいいね・フォローお願いします!


この内容はコード・構成ともにMedium版と全く同一ですが、Qiitaに合わせて少し整えました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?