I made a rope shooter script but for some reason I cant swing. I shoot the rope and get stuck mid air unable to move. You shoot the rope by holding R and when you release R the rope dissapears. After it dissapears I cant shoot it again.
Any help please?
--// Variables:
local plr = game.Players.LocalPlayer
local char = plr.Character
local head = char:FindFirstChild("Head")
local athA = Instance.new("Attachment", head)
local athPart = game.Workspace.AttachPart
local athB = Instance.new("Attachment", athPart)
athA.Position = Vector3.new(0,0,-1)
local rope = Instance.new("RopeConstraint", head)
local length = (head.Position - athPart.Position).magnitude
local uis = game:GetService("UserInputService")
isSwinging = false
--// Functions:
uis.InputBegan:connect(function(key)
if key.KeyCode == Enum.KeyCode.R then
if isSwinging == false then
isSwinging = true
rope.Attachment0 = athA
rope.Attachment1 = athB
rope.Length = length
rope.Visible = true
end
end
end)
uis.InputEnded:connect(function(key)
if key.KeyCode == Enum.KeyCode.R then
if isSwinging == true then
isSwinging = false
rope.Attachment0:Destroy()
rope.Attachment1:Destroy()
end
end
end)
https://vimeo.com/user90972315/review/296864730/5403a5d191 Here is how it looks like.
LocalScript inside StarterCharacterScripts

3 comments
You forgot to destroy the rope once the key is released. ( just a small help )
And one more thing, parent the Attachment and RopeConstraint once the key is pressed, and set their parent to nil once the key is released, if this solves your question, then add this to your title; [ Solved ]
I tried to destoy the rope, still same problem. I get stuck and can`t move and cant shoot the rope again. I saw the rope dissapeared so it worked but it didnt fixed the issue. Also how do I parent the Attachment and the RopeConstraint? Could you please explain why should I do this and how?