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?

60秒で作る!クリックで爆発するPart【Roblox開発 #2】

Posted at

🎓 この教材で学べること

  • ClickDetector の使い方
  • Explosion の生成と設定方法
  • Part にイベントを仕込む基礎
  • イベント発火型のインタラクション処理
  • Roblox Studioでの簡易トラブルシュート

🧱 準備するもの

項目 内容
1 Roblox Studio を起動する
2 Scene に「Part」を1つ配置
3 そのPartに「ClickDetector」と「Script」を追加

🔧 スクリプト全体(Scriptの中身)

-- 親のPartを取得
local part = script.Parent

-- ClickDetectorのクリックイベントに接続
part.ClickDetector.MouseClick:Connect(function(player)
	
	-- 爆発を作成して位置を指定
	local explosion = Instance.new("Explosion")
	explosion.Position = part.Position
	explosion.BlastRadius = 10 -- 爆風の範囲
	explosion.BlastPressure = 500000 -- 爆風の強さ
	
	explosion.Parent = workspace -- ワールドに追加して有効化
	
	-- 爆発後、Partを消す(任意)
	part:Destroy()
end)

🧠 解説ポイント

行数 解説内容
2 script.Parent でクリック対象のPartを指定
4 ClickDetector.MouseClick でプレイヤーのクリックを検出
6〜10 Explosion を作成し、位置や範囲、圧力を設定
12 Workspaceに追加 → 爆発が発生!
14 おまけ:クリックされたPartを削除(派手に見せたいときに◎)

🔍 よくあるつまずきポイント

問題 対処方法
Partが爆発しない ClickDetector が入っているか、確認
何も起きない Explosion.Parent = workspace を忘れていないか確認
破壊されたくないオブジェクトも壊れる Explosion.DestroyJointRadiusPercent = 0 を設定して調整可能

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?