So I made a tool that if you click the player it makes a rope attachment to the other player the person clicked on. But when you make the attachment. It makes the rope real close to you. How can I stretch it so it makes a good distance? Here is the server script inside the tool:
local tool = script.Parent
local backpack = tool.Parent
local player = backpack.Parent
local character = player.Character or player.CharacterAdded:Wait()
local root = character:WaitForChild("HumanoidRootPart")
local sendMouseTarget = tool:WaitForChild("SendMouseTarget")
local canUseMouseTargetReceived = true
local function makeAttachment(part, pos)
local attachment = Instance.new("Attachment")
local pos = pos or Vector3.new()
attachment.Position = pos
attachment.Parent = part
return attachment
end
local function connectWithRopeConstraint(part0, part1)
local newRope = Instance.new("RopeConstraint")
local dist = (part0.Position - part1.Position).Magnitude
local attachment0 = makeAttachment(part0)
local attachment1 = makeAttachment(part1)
newRope.Attachment0 = attachment0
newRope.Attachment1 = attachment1
newRope.Visible = true
newRope.Length = dist
newRope.Parent = part0
end
local function receiveMouseTarget(player, target)
if canUseMouseTargetReceived then
canUseMouseTargetReceived = false
if type(target) == "userdata" and target then
if target:IsA("BasePart") then
connectWithRopeConstraint(root, target)
end
end
wait(1)
canUseMouseTargetReceived = true
end
end
sendMouseTarget.OnServerEvent:Connect(receiveMouseTarget)
and this is the client script inside the tool:
local players = game:GetService("Players")
local client = players.LocalPlayer
local mouse = client:GetMouse()
local character = client.Character or client.CharacterAdded:Wait()
local tool = script.Parent
local sendMouseTargetEvent = tool:WaitForChild("SendMouseTarget")
local function sendMouseTargetToServer()
sendMouseTargetEvent:FireServer(mouse.Target)
end
tool.Activated:Connect(sendMouseTargetToServer)