I can only shoot a rope once but cant shoot it again, why? [SOLVED]
Asked by
6 years ago Edited 6 years ago
I have a script of a grapple hook thingy.. that shoots rope constraint and you can use it to swing. I want to do some kind of lava level where you need to swing above the lava without dying (falling). But for some reason when I shoot the rope, it shoots it only ONCE.. and I cant shoot it again.
I placed the code inside LocalScript and placed it inside StarterCharacterScripts.
Oh and also, when I was in the game I tried to delete the script inside my character and put it back in, and I could shoot the rope again. I thought of making a script that gives me a new one and deletes the old one, I dont really know how to do it. I wanted to know if there is an "easier" fix to this problem.
03 | local plr = game.Players.LocalPlayer |
04 | local char = plr.Character |
05 | local head = char:FindFirstChild( "Head" ) |
07 | local athA = Instance.new( "Attachment" , head) |
08 | local athPart = game.Workspace.AttachPart |
09 | local athB = Instance.new( "Attachment" , athPart) |
10 | athA.Position = Vector 3. new( 0 , 0 ,- 1 ) |
11 | local rope = Instance.new( "RopeConstraint" , head) |
12 | local length = (head.Position - athPart.Position).magnitude |
13 | local uis = game:GetService( "UserInputService" ) |
19 | uis.InputBegan:connect( function (key) |
20 | if key.KeyCode = = Enum.KeyCode.R then |
21 | if isSwinging = = false then |
23 | rope.Attachment 0 = athB |
24 | rope.Attachment 1 = athA |
31 | uis.InputEnded:connect( function (key) |
32 | if key.KeyCode = = Enum.KeyCode.R then |
33 | if isSwinging = = true then |
34 | rope.Attachment 0 :Destroy() |
35 | rope.Attachment 1 :Destroy() |
https://vimeo.com/user90972315/review/297152618/40319cd20c
Video of me showing how I am removing and adding back the script, and it works.
Found the solution, I removed the lines that destroy the attachments