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.
--// 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 = athB
rope.Attachment1 = athA
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
rope.Attachment0:Destroy() -- remove it
rope.Attachment1:Destroy() -- remove it
rope:Destroy()
isSwinging = false
end
end
end)
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

6 comments
Do you have a debounce of when you can shoot or not? Life if you are loaded and when you are unloaded.
I mean, I made the "isSwinging".. I dont know if its correct tho and if it works. Is is good?
I got it.
The length also needs set every time.
I edited my answer, take a look.
I already fixed it. Your code doesnt work, you should leave the attachments and not destroy them. Thank you anyways for trying when nobody else really did besides a few. :)