Grappler issue, any help?

making a grappler system, three problems:
a visual problem, the rope starts from the side, and makes it’s way to the mouse position, i want it to come straight from the hand, and to the mouse pos.

i made it so that there is a limit to how far you can grapple, but it’s not working, the part even can grapple to the sun.

if you grapple and move, you will trip as soon as you hit the invisible target.

code:

local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Mouse = Player:GetMouse()
local UserInputService = game:GetService("UserInputService")
local RightArm = script.Parent.RightHand
local TweenService = game:GetService("TweenService")
local canGrappleAgain = true
local MaxGrappleDistance = 35
local waitTime = 0.75
Player.CameraMode = Enum.CameraMode.LockFirstPerson 
game.Workspace.Camera.FieldOfView = 100
UserInputService.InputBegan:Connect(function(input, gameProcessed)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		if input.KeyCode == Enum.KeyCode.E then
			if canGrappleAgain then
				canGrappleAgain = false
				local Target = Instance.new("Part")
				Target.Position = Vector3.new(RightArm.Position)
				Target.Transparency = 1
				local PartMove = TweenInfo.new(
					1,
					Enum.EasingStyle.Quad,
					Enum.EasingDirection.Out,
					0,
					false,
					0
				)
				local PT = TweenService:Create(Target, PartMove, {Position = Mouse.Hit.p})
				Target.Parent = game.Workspace
				PT:Play()
				PT.Completed:Connect(function()
					if Player:DistanceFromCharacter(Vector3.new(Target.Position.X, Target.Position.Y, Target.Position.Z)) > MaxGrappleDistance then
						Target:Destroy()
					end
					Target.Anchored = true
					Target.CanCollide = false
				end)
				local A0 = Instance.new("Attachment")
				A0.Parent = RightArm
				local A1 = Instance.new("Attachment")
				A1.Parent = Target
				local Spring = Instance.new("SpringConstraint")
				Spring.Attachment0 = A0
				Spring.Attachment1 = A1
				Spring.Visible = true
				Spring.Color = BrickColor.new(26)
				Spring.Coils = 6
				Spring.Radius = 0.35
				local CA = TweenInfo.new(
					waitTime,
					Enum.EasingStyle.Quad,
					Enum.EasingDirection.Out,
					0,
					true,
					0
				)
				local CT = TweenService:Create(Spring, CA, {Coils = 0})
				Spring.Parent = A0.Parent
				CT:Play()
				wait(waitTime)
				CT.Completed:Connect(function()
					Target:Destroy()
					canGrappleAgain = true
				end)
			end
		end
	end
end)

Any help fixing my problems please?

1 Like