学ぶ
エンジンクラス
Tool

*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。


概要
方法
継承されたメンバー
継承者
コードサンプル
爆発ツールの例
local tool = script.Parent
local function explode(point)
local e = Instance.new("Explosion")
e.DestroyJointRadiusPercent = 0 -- 爆発を致命的でないようにする
e.Position = point
e.Parent = workspace
end
local function onActivated()
-- ツールがアクティブになったときのHumanoidを取得
local human = tool.Parent.Humanoid
-- 現在Humanoidが狙っている地点でexplodeを呼び出す
explode(human.TargetPoint)
end
tool.Activated:Connect(onActivated)
剣ツールのサンプル
local tool = script.Parent
local function onTouch(partOther)
-- 最初に、触れたパートがヒューマノイドの一部であるかどうかを確認します
local humanOther = partOther.Parent:FindFirstChild("Humanoid")
-- 非ヒューマノイドによる接触を無視します
if not humanOther then
return
end
-- 剣を持っているヒューマノイドによる接触を無視します
if humanOther.Parent == tool.Parent then
return
end
humanOther:TakeDamage(5)
end
-- スラッシュアニメーションをトリガーします
local function slash()
-- デフォルトのキャラクタースクリプトは「toolanim」StringValueをリッスンします
local value = Instance.new("StringValue")
value.Name = "toolanim"
value.Value = "スラッシュ" -- 別の例: 突き
value.Parent = tool
end
tool.Activated:Connect(slash)
tool.Handle.Touched:Connect(onTouch)

APIリファレンス
プロパティ
CanBeDropped
並列読み取り
機能: Input
Tool.CanBeDropped:boolean

Enabled
並列読み取り
機能: Input
シミュレーションへのアクセス
Tool.Enabled:boolean
コードサンプル
スーパージャンプツール
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local tool = Instance.new("Tool")
tool.Name = "SuperJump"
tool.RequiresHandle = false
tool.Parent = player.Backpack
function toolActivated()
humanoid.JumpPower = 150
tool.Enabled = false
task.wait(5)
tool.Enabled = true
humanoid.JumpPower = 50
end
tool.Activated:Connect(toolActivated)
tool.Unequipped:Connect(function()
humanoid.JumpPower = 50
end)

Grip
並列読み取り
機能: Input
シミュレーションへのアクセス
Tool.Grip:CFrame
コードサンプル
グリップスティック
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local tool = Instance.new("Tool")
tool.Name = "Stick"
tool.Parent = player.Backpack
local handle = Instance.new("Part")
handle.Name = "Handle"
handle.Parent = tool
handle.Size = Vector3.new(0.1, 3, 0.1)
handle.Color = Color3.fromRGB(108, 88, 75) -- 茶色
tool.Activated:Connect(function()
print(tool.Grip)
print(tool.GripUp)
print(tool.GripRight)
print(tool.GripForward)
print(tool.GripPos)
end)

GripForward
非表示
複製されていません
並列読み取り
機能: Input
Tool.GripForward:Vector3
コードサンプル
グリップスティック
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local tool = Instance.new("Tool")
tool.Name = "Stick"
tool.Parent = player.Backpack
local handle = Instance.new("Part")
handle.Name = "Handle"
handle.Parent = tool
handle.Size = Vector3.new(0.1, 3, 0.1)
handle.Color = Color3.fromRGB(108, 88, 75) -- 茶色
tool.Activated:Connect(function()
print(tool.Grip)
print(tool.GripUp)
print(tool.GripRight)
print(tool.GripForward)
print(tool.GripPos)
end)

GripPos
非表示
複製されていません
並列読み取り
機能: Input
Tool.GripPos:Vector3
コードサンプル
グリップスティック
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local tool = Instance.new("Tool")
tool.Name = "Stick"
tool.Parent = player.Backpack
local handle = Instance.new("Part")
handle.Name = "Handle"
handle.Parent = tool
handle.Size = Vector3.new(0.1, 3, 0.1)
handle.Color = Color3.fromRGB(108, 88, 75) -- 茶色
tool.Activated:Connect(function()
print(tool.Grip)
print(tool.GripUp)
print(tool.GripRight)
print(tool.GripForward)
print(tool.GripPos)
end)

GripRight
非表示
複製されていません
並列読み取り
機能: Input
Tool.GripRight:Vector3
コードサンプル
グリップスティック
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local tool = Instance.new("Tool")
tool.Name = "Stick"
tool.Parent = player.Backpack
local handle = Instance.new("Part")
handle.Name = "Handle"
handle.Parent = tool
handle.Size = Vector3.new(0.1, 3, 0.1)
handle.Color = Color3.fromRGB(108, 88, 75) -- 茶色
tool.Activated:Connect(function()
print(tool.Grip)
print(tool.GripUp)
print(tool.GripRight)
print(tool.GripForward)
print(tool.GripPos)
end)

GripUp
非表示
複製されていません
並列読み取り
機能: Input
Tool.GripUp:Vector3
コードサンプル
グリップスティック
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local tool = Instance.new("Tool")
tool.Name = "Stick"
tool.Parent = player.Backpack
local handle = Instance.new("Part")
handle.Name = "Handle"
handle.Parent = tool
handle.Size = Vector3.new(0.1, 3, 0.1)
handle.Color = Color3.fromRGB(108, 88, 75) -- 茶色
tool.Activated:Connect(function()
print(tool.Grip)
print(tool.GripUp)
print(tool.GripRight)
print(tool.GripForward)
print(tool.GripPos)
end)

ManualActivationOnly
並列読み取り
機能: Input
Tool.ManualActivationOnly:boolean
コードサンプル
スプリントツール
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local tool = Instance.new("Tool")
tool.Name = "Sprint"
tool.RequiresHandle = false
tool.Parent = player:WaitForChild("Backpack")
function toolActivated()
humanoid.WalkSpeed = 30
tool.ManualActivationOnly = true
task.wait(5)
tool.ManualActivationOnly = false
humanoid.WalkSpeed = 16
end
tool.Activated:Connect(toolActivated)
tool.Unequipped:Connect(function()
humanoid.WalkSpeed = 16
end)

RequiresHandle
並列読み取り
機能: Input
Tool.RequiresHandle:boolean

ToolTip
並列読み取り
機能: Input
Tool.ToolTip:string

方法
Activate
機能: Input
Tool:Activate():()
戻り値
()
コードサンプル
透明ツール
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character
local tool = Instance.new("Tool")
tool.Name = "透明ツール"
tool.RequiresHandle = false
tool.Parent = player.Backpack
local invisible = false
local function toolActivated()
if invisible then
return
end
invisible = true
for _, bodypart in pairs(character:GetChildren()) do
if bodypart:IsA("MeshPart") or bodypart:IsA("Part") then
bodypart.Transparency = 1
end
end
task.wait(3)
tool:Deactivate()
task.wait(1)
invisible = false
end
local function toolDeactivated()
if not invisible then
return
end
for _, bodypart in pairs(character:GetChildren()) do
if bodypart.Name ~= "HumanoidRootPart" then
if bodypart:IsA("MeshPart") or bodypart:IsA("Part") then
bodypart.Transparency = 0
end
end
end
end
local function toolEquipped()
tool:Activate()
end
tool.Equipped:Connect(toolEquipped)
tool.Activated:Connect(toolActivated)
tool.Deactivated:Connect(toolDeactivated)
tool.Unequipped:Connect(toolDeactivated)

Deactivate
機能: Input
Tool:Deactivate():()
戻り値
()
コードサンプル
透明ツール
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character
local tool = Instance.new("Tool")
tool.Name = "透明ツール"
tool.RequiresHandle = false
tool.Parent = player.Backpack
local invisible = false
local function toolActivated()
if invisible then
return
end
invisible = true
for _, bodypart in pairs(character:GetChildren()) do
if bodypart:IsA("MeshPart") or bodypart:IsA("Part") then
bodypart.Transparency = 1
end
end
task.wait(3)
tool:Deactivate()
task.wait(1)
invisible = false
end
local function toolDeactivated()
if not invisible then
return
end
for _, bodypart in pairs(character:GetChildren()) do
if bodypart.Name ~= "HumanoidRootPart" then
if bodypart:IsA("MeshPart") or bodypart:IsA("Part") then
bodypart.Transparency = 0
end
end
end
end
local function toolEquipped()
tool:Activate()
end
tool.Equipped:Connect(toolEquipped)
tool.Activated:Connect(toolActivated)
tool.Deactivated:Connect(toolDeactivated)
tool.Unequipped:Connect(toolDeactivated)

イベント
Activated
機能: Input
Tool.Activated():RBXScriptSignal

Deactivated
機能: Input
Tool.Deactivated():RBXScriptSignal

Equipped
機能: Input
Tool.Equipped(mouse:Mouse):RBXScriptSignal
パラメータ
mouse:Mouse
コードサンプル
プレイヤーがツールを装備したときに印刷する
local Tool = script.Parent
local function onEquipped(_mouse)
print("ツールが装備されました")
end
Tool.Equipped:Connect(onEquipped)

Unequipped
機能: Input
Tool.Unequipped():RBXScriptSignal

©2026 Roblox Corporation。Roblox(ロブロックス)、RobloxロゴおよびPowering Imaginationは、米国並びにその他の国における登録商標および非登録商標です。