Spiderman script anchoring arm

I am trying to make it where when you hold click, a rope constraint will connect to the point of your cursor and pull your avatar there.
Whenever I click on an anchored part, my character’s right arm gets anchored somehow. It is not anchored in the properties but it gets frozen up. I don’t think that is the intended behavior for ropes.
Here is my script:

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

local web = nil

mouse.Button1Down:Connect(function()
	if mouse.Target == nil or not plr.Character then return end
	local a = Instance.new("Attachment", mouse.Target)
	a.WorldPosition = mouse.Hit.Position
	web = Instance.new("RopeConstraint")
	web.Length = (mouse.Hit.Position - plr.Character["Right Arm"].Position).Magnitude
	web.Attachment1 = a
	web.Attachment0 = plr.Character["Right Arm"].RightGripAttachment
	web.Visible = true
	web.Color = BrickColor.new("Institutional white")
	web.Parent = plr.Character["Right Arm"]
	plr.Character.Humanoid.PlatformStand = true
end)

mouse.Button1Up:Connect(function()
	if web then
		web:Destroy() web = nil
		plr.Character.Humanoid.PlatformStand = false
	end
end)

while true do
	wait(0.05)
	if web then
		web.Length -= 0.5
		if web.Length <= 0 then
			web:Destroy()
			web = nil
			plr.Character.Humanoid.PlatformStand = false
		end
	end
end

As far as I can tell, the problem seems to be that everything is done from a LocalScript, when I did a test with a RemoteEvent and a Script, it seemed to work.
This is a pretty unclean test, but heres the code:
It requires a RopeConstraint in the Right Arm already setup with an Attachment in the arm as well, in Attachment0

Local Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SetRope = ReplicatedStorage:WaitForChild("SetRope")

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()


mouse.Button1Down:Connect(function()
	print("bdown")
	if mouse.Target == nil or not plr.Character then return end
	SetRope:FireServer(mouse.Target, mouse.Hit.Position)
end)

mouse.Button1Up:Connect(function()
	SetRope:FireServer()
end)

Server Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")


local SetRope = ReplicatedStorage:WaitForChild("SetRope")

SetRope.OnServerEvent:Connect(function(player, part, position)
	local ch = player.Character
	if ch then
		local rarm = ch:FindFirstChild("Right Arm")
		if rarm then
			local rope = rarm:FindFirstChildOfClass("RopeConstraint")
			if rope then
				if part ~= nil then
					local a = Instance.new("Attachment", part)
					a.WorldPosition = position

					rope.Length = (position - rarm.Position).Magnitude
					rope.Attachment1 = a
					rope.Enabled = true
				else
					rope.Enabled = false
				end
			end
		end
	end
end)

Also: there is a winch part of RopeConstraints, which may be able to replace the infinite loop

3 Likes