im making a grab system for a rock climbing game, but it doesnt work as i want it to atm. issue in title
code is a big fat mess, could be 100x better but here it is:
mouse=game.Players.LocalPlayer:GetMouse()
leftarmreach=Instance.new("Part",workspace.CurrentCamera)
leftarmreach.Size=Vector3.new(1,1,1)
leftarmreach.Massless=true
leftarmreach.CanCollide=false
leftarmreachatt=Instance.new("Attachment",leftarmreach)
rightarmreach=Instance.new("Part",workspace.CurrentCamera)
rightarmreach.Size=Vector3.new(1,1,1)
rightarmreach.Massless=true
rightarmreach.CanCollide=false
rightarmreachatt=Instance.new("Attachment",rightarmreach)
leftarmreachAP=Instance.new("AlignPosition",leftarmreach)
leftarmreachAP.RigidityEnabled=true
leftarmreachAP.Mode="OneAttachment"
leftarmreachAP.Attachment0=leftarmreachatt
rightarmreachAP=Instance.new("AlignPosition",rightarmreach)
rightarmreachAP.RigidityEnabled=true
rightarmreachAP.Mode="OneAttachment"
rightarmreachAP.Attachment0=rightarmreachatt
leftarmreachrope=Instance.new("RopeConstraint",leftarmreach)
rightarmreachrope=Instance.new("RopeConstraint",rightarmreach)
leftarmreachrope.Attachment0=leftarmreachatt
rightarmreachrope.Attachment0=rightarmreachatt
leftarmreachrope.Attachment1=game.Players.LocalPlayer.Character:FindFirstChild("Torso"):FindFirstChild("BodyFrontAttachment")
rightarmreachrope.Attachment1=game.Players.LocalPlayer.Character:FindFirstChild("Torso"):FindFirstChild("BodyFrontAttachment")
leftarmreachrope.Length=5.5
rightarmreachrope.Length=5.5
game:GetService("RunService"):BindToRenderStep("reach_changepos",Enum.RenderPriority.Camera.Value + 1,function()
leftarmreachAP.Position=workspace.CurrentCamera.CFrame.Position+workspace.CurrentCamera.CFrame.LookVector*5+workspace.CurrentCamera.CFrame.RightVector*-1+workspace.CurrentCamera.CFrame.UpVector*-0.5
rightarmreachAP.Position=workspace.CurrentCamera.CFrame.Position+workspace.CurrentCamera.CFrame.LookVector*5+workspace.CurrentCamera.CFrame.RightVector*1+workspace.CurrentCamera.CFrame.UpVector*-0.5
end)
mouse.Button1Down:Connect(function()
game:GetService("RunService"):BindToRenderStep("reach_LAhold",Enum.RenderPriority.Camera.Value + 1,function()
for i,v in pairs(workspace:GetPartsInPart(leftarmreach)) do
if v:GetAttribute("climbable") then
leftarmreach.Anchored=true
end
end
end)
end)
mouse.Button2Down:Connect(function()
game:GetService("RunService"):BindToRenderStep("reach_RAhold",Enum.RenderPriority.Camera.Value + 1,function()
for i,v in pairs(workspace:GetPartsInPart(rightarmreach)) do
if v:GetAttribute("climbable") then
rightarmreach.Anchored=true
end
end
end)
end)
mouse.Button1Up:Connect(function()
game:GetService("RunService"):UnbindFromRenderStep("reach_LAhold")
leftarmreach.Anchored=false
end)
mouse.Button2Up:Connect(function()
game:GetService("RunService"):UnbindFromRenderStep("reach_RAhold")
rightarmreach.Anchored=false
end)