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でassistant その203

Posted at

概要

robloxでassistant、やってみた。
練習問題やってみた。

練習問題

ProximityPromptServiceを使え。

写真

image.png

サンプルコード

Script


local ProximityPromptService = game:GetService("ProximityPromptService")
print("ok")
-- プレイヤーがプロンプトをトリガーしたとき
ProximityPromptService.PromptTriggered:Connect(function(prompt, player)
	print(player.Name .. " が " .. prompt.ObjectText .. " を使った")
	-- ここでアイテムを渡す、ドアを開けるなどの処理を記述
end)

-- プレイヤーがプロンプトを表示したとき
ProximityPromptService.PromptShown:Connect(function(prompt, player)
	print(player.Name .. " に " .. prompt.ActionText .. " が表示された")
end)

-- プレイヤーがプロンプトを非表示にしたとき
ProximityPromptService.PromptHidden:Connect(function(prompt, player)
	print(player.Name .. " の画面から " .. prompt.ActionText .. " が消えた")
end)

wait(3)
print("ok1")
local part = Instance.new("Part", workspace)
part.Position = Vector3.new(0, 1, -10)
local prompt = Instance.new("ProximityPrompt", part)
prompt.ActionText = "消す"
prompt.UIOffset = Vector2.new(0, -20)
prompt.KeyboardKeyCode = Enum.KeyCode.E
prompt.ObjectText = "このパーツ"
prompt.Enabled = true
prompt.Triggered:Connect(function(player)
	part:Destroy()
end)

以上。

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?