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

Is there a way to remove and improve the RopeConstraint?

Asked by 5 years ago

I made a script of a RopeConstraint but ran into couple issues.

The scripts makes it so that when I click the mouse button it will shoot a rope.

The only problem is that I need to tell the script the length of the rope but I want it to be the length between the character and the point where my mouse clicked but I dont know how to make it. I also dont know how to remove the rope after im done using it. I tried to remove it but I cant and it wont work. Any help please?

local wa = game.Workspace.WebAttachment
local plr = game.Players.LocalPlayer
local char = plr.Character
local head = char:FindFirstChild("Head")

local uis = game:GetService("UserInputService")

uis.InputBegan:Connect(function(input, GameProcessed)
    if input.UserInputType == Enum.UserInputType.MouseButton1 then

        local attachmentA = Instance.new("Attachment", wa)
        attachmentA.Position = Vector3.new(input.Position)

        local attachmentB = Instance.new("Attachment", head)
        attachmentB.Position = Vector3.new(0,0,-1)

        local web = Instance.new("RopeConstraint", wa)
        game.Workspace.WebSound:Play()
        wait(0.2)
        web.Attachment0 = attachmentA
        web.Attachment1 = attachmentB
        web.Visible = true
        web.Color = BrickColor.new("White")
        web.Length = (input.Position),(head) --I tried to do something but, as you can see it didn`t really worked out.. I tried finding an answer by searching it via Google but couldnt find one.

    end
end)

uis.InputEnded:Connect(function(input, GameProcessed)
    if input.UserInputType == Enum.UserInputType.MouseButton1 then
        head:FindFirstChild("web")
        web:Destroy()
    end
end)
0
Just so you know, the parent argument to Instance.new is deprecated, you should be saying just "Attachment" and not "Attachment", wa... etc. Always assign the parent property LAST, rather than first. User#19524 175 — 5y

Answer this question