RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"make a grappling hook with physics the tool is called grap make the rope visible"
-- local script inside the Grap tool local tool = script.Parent local player = game.Players.LocalPlayer local mouse = player:GetMouse() local rope = Instance.new("RopeConstraint") local isFired = false local function createRope(target) rope.Parent = game.Workspace rope.Attachment0 = tool.Handle.Attachment0 rope.Attachment1 = target rope.Visible = true rope.Length = (tool.Handle.Position - target.Position).Magnitude end local function fire() if not isFired then isFired = true local ray = Ray.new(tool.Handle.Position, mouse.Hit.p - tool.Handle.Position) local part, position = game.Workspace:FindPartOnRay(ray, player.Character, false, true) if part then local attachment = Instance.new("Attachment", part) attachment.Position = part.CFrame:ToObjectSpace(CFrame.new(position)).p createRope(attachment) end end end local function release() if isFired then isFired = false rope.Parent = nil if rope.Attachment1 then rope.Attachment1:Destroy() end end end tool.Activated:Connect(fire) tool.Deactivated:Connect(release)