Created
April 10, 2024 07:26
-
-
Save gamebox777/c6fde7b3702448cbfa49179aa06d139d to your computer and use it in GitHub Desktop.
roblox 当たったら死ぬ処理 ロブロックス
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- このスクリプトを死亡トリガーとしたいブロックにアタッチしてください。 | |
| -- タッチイベントを検出する関数 | |
| local function onTouched(other) | |
| -- otherはタッチしたオブジェクト。この場合はプレイヤーのキャラクターの一部。 | |
| local character = other.Parent -- プレイヤーのキャラクターを取得 | |
| local humanoid = character:FindFirstChildOfClass("Humanoid") -- Humanoidオブジェクトを取得 | |
| -- Humanoidが存在し、生きている場合にのみ実行 | |
| if humanoid and humanoid.Health > 0 then | |
| humanoid.Health = 0 -- HumanoidのHealthを0に設定し、キャラクターを「死亡」状態にする | |
| end | |
| end | |
| -- このスクリプトがアタッチされたパーツのTouchedイベントに、上記の関数を接続 | |
| script.Parent.Touched:Connect(onTouched) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment