Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 1 year ago
Edited 1 year ago

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)
0
theres some miss spellings and alot of errors Puppynniko 1059 — 1y
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. ChromeDarkMode 15 — 1y
0
Okay thanks 410eren 6 — 1y

2 answers

Log in to vote
0
Answered by 1 year ago

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
0
thank you so much 410eren 6 — 1y
Ad
Log in to vote
0
Answered by 1 year ago

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)

Answer this question