Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how do i create a rope between player and a part? (solved)

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)

3 comments

0

theres some miss spellings and alot of errors

0

This code is just a mess, there are so many things wrong with it. Open output and go through each error and fix them individually, after you have fixed them to your ability, come back if it still doesn't work.

0

Okay thanks

2 answers

✓ Accepted answer

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

1 comment

0

thank you so much

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.