Shooting Spring Grappling Gun To Bring Part to Player

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
    I want the player to be stationary not able to move and the non anchored part to come to the player who shot the spring grappling gun

  2. What is the issue?
    player stays put but the unanchored, unwelded part does not move. The spring is attached to the base part and then the hook part

  3. What solutions have you tried so far?
    tried unanchoring the part I want to move, tried anchoring the HumanoidRootPart, anchoring the Handle of the tool grappling hook shooter, making the part I want to come to me weightless. tried using a hat instead of a part, but can’t get anything to come to the player. Tried anchoring the base also. Tried increasing the stiffness by 10x.

ty so much for taking the time to help, I know its something stupid that I’m forgetting :frowning:

local runService = game:GetService("RunService")
local players = game:GetService("Players")
local tweenService = game:GetService("TweenService")

local tool = script.Parent
local base = tool:WaitForChild("Base")
local spring = base.Spring
local hook = tool:WaitForChild("Hook")
local hookWeld = hook.HookWeld
local hookReference = tool:WaitForChild("HookReference")
local messageEvent = script:WaitForChild("MessageEvent")
local activated = script:WaitForChild("Activated")
local newPart = game.Workspace.NewPart


--ONLY CLIENT
local player = nil
local mouse = nil
local currentTween = nil



-----------------------------------------------------------------------------------------------------------------
local GrappleGun= {}


local function toggleHumGrapState(active)
	local humanoid = player.Character and player.Character:FindFirstChild("Humanoid")
	
	if humanoid then
		if active then
			humanoid:SetStateEnabled(Enum.HumanoidStateType.Running, false)
		--	humanoid:ChangeState(Enum.HumanoidStateType.Physics)
		else
			humanoid:SetStateEnabled(Enum.HumanoidStateType.Running, true)
			--humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
		end
	end
end


local function clientInit()
	player = players.LocalPlayer
	print(tostring(player.Character.HumanoidRootPart))
	mouse = player:GetMouse()
	mouse.TargetFilter = player.Character
	tool.Activated:Connect(function()
		
		if not GrappleGun.IsActivated() and mouse.Target then--mouse.target gets nil if mouse is on the sky
			messageEvent:FireServer(true, mouse.Hit.Position)
			toggleHumGrapState(true)
		
		end
	end)
	
	tool.Deactivated:Connect(function()
		messageEvent:FireServer(false)
		toggleHumGrapState(false)
		
	end)
	
	tool.Unequipped:Connect(function()
		messageEvent:FireServer(false)
		toggleHumGrapState(false)
	end)
end

local function serverInit()
	messageEvent.OnServerEvent:Connect(function(player, _activated, targetPosition)
		activated.Value = _activated
	
		if GrappleGun.IsActivated() then
			local char = player.Character
			char:WaitForChild("HumanoidRootPart").Anchored = true
			GrappleGun.Fire(targetPosition)
		else
			local char = player.Character
			char:WaitForChild("HumanoidRootPart").Anchored = false

			GrappleGun.Reset()
		end
	end)
end

local function init()
	if runService:IsClient() then
		clientInit()
	end

	if runService:IsServer() then
		serverInit()
	end
end

function GrappleGun.IsActivated()
	return activated.Value
end


function GrappleGun.Fire(targetPosition)
	
	local initPosition = hookReference.Position
	local distance = (targetPosition - initPosition).Magnitude
	
	hookWeld.Enabled = false
	hook.Anchored = true
	
	wait()
	
	hook.Position = targetPosition
	spring.FreeLength = distance
	
	local info = TweenInfo.new(distance/100, Enum.EasingStyle.Linear)
	--local tween = tweenService:Create(spring, info, {FreeLength = 1})
	
	--tween:Play()
	--currentTween = tween
end


function GrappleGun.Reset()
	if currentTween then
		currentTween:Cancel()
	end
	
	hook.CFrame = hookReference.CFrame
	hookWeld.Enabled = true
	hook.Anchored = false
	
	spring.FreeLength = 1
end




--------------------------------------------------------------------------------------------------------------------

init()

return GrappleGun