i want to make a parkour game, but first off all i need to make rope mechanic. There will be a lot same named part that for rope and the certain part be close enough to player.
my code, its not working. How do i fix it? (i combined 3 diffirent codes from devforum):
local Part = game.woskpace.roper local RootPart = game.Players.LocalPlayer.HumanoidRootPartprefer local Distance = (Part.Position - Vector3.new(RootPart.Position.X,Part.Position.Y,RootPart.Position.Z)).Magnitude huma= game.Players:FindFirstChild("Left Arm") bri = script.Parent.Parent.Workspace.roper local Player = game.Players.LocalPlayer local Character = Player.Character local UserInputService = game:GetService("UserInputService") UserInputService.InputBegan:Connect(function(key) if key.KeyCode == Enum.KeyCode.Q then if Distance <= 23 then if bri.RodConstraint.Attachment1 == bri.RodConstraint.Attachment0 then bri.RodConstraint2.Attachment1 = huma.Rop2 bri.RodConstraint.Attachment1 = huma.Rop else bri.RodConstraint.Attachment1 = bri.RodConstraint.Attachment0 bri.RodConstraint2.Attachment1 = bri.RodConstraint2.Attachment0 end end end end)
part1 and part2 are baseParts. If you want to connect players, use their HumanoidRootParts, or torsos(r6)
local part1 = workspace.Part1 local part2 = workspace.Part2 connectorPart = Instance.new("Part", workspace) connectorPart.Anchored = true connectorPart.CanCollide = false connectorPart.BottomSurface = "Smooth" connectorPart.TopSurface = "Smooth" local distance = (part1.Poition - part2.Position).Magnitude connectorPart.Size = Vector3.new(1, 1, distance) local offset = CFrame.new(0, 0, - distance / 2) connectorPart.CFrame = CFrame.new(part1.Position, part2.Position) * offset
yo guys i made a new code (this using ProximityPrompt)
script.Parent.ProximityPrompt.Triggered:Connect(function(player) local char = player.Character or player.CharacterAdded:Wait() -- Get the player character local Rope = Instance.new("RopeConstraint") Rope.Parent = script.Parent local At1 = Instance.new("Attachment") local At2 = Instance.new("Attachment") At1.Parent = script.Parent At2.Parent = char.LeftHand At1.Name = "Attachment0" At2.Name = "Attachment1" Rope.Attachment0 = At1 -- You might wanna change this to what it was before Rope.Attachment1 = At2 -- You might wanna change this to what it was before Rope.Length = 25 Rope.Visible = true end)