Создаем скрипт для инструмента в Toolbox
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Debris = game:GetService("Debris")
local function onPlayerAdded(player)
local character = player.Character or player.CharacterAppearance
if character then
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid.EquippedToolChanged:Connect(function()
local equippedTool = humanoid.EquippedTool
if equippedTool then
local script =
Instance.new ("Script")
script.Parent = equippedTool
script.Source = [[
local function onClick()
local rope = workspace:FindFirstChild("Rope")
if rope then
local connection = rope.TouchEnded:Connect(function()
local part =
Instance.new ("Part")
part.Name = "ConnectedItem"
part.Size =
Vector3.new (0.2, 0.2, 0.2)
part.Position = equippedTool.CFrame.Position +
Vector3.new (0, 2, 0)
part.Anchored = true
part.CanCollide = false
part.Transparency = 0.5
part.Parent = workspace
local debounce =
Instance.new ("BoolValue")
debounce.Name = "IsAttachedToRope"
debounce.Value = true
debounce.Parent = part
connection:Disconnect()
end
else
warn("Rope not found in workspace.")
end
end
local tool = script.Parent
tool.Activated:Connect(onClick)
]]
Debris:AddItem(script, 10)
end
end)
end
end
end
Players.PlayerAdded:Connect(onPlayerAdded)