How to Maintain Tool Grip when Using ScaleTool()

hey im make a script that will changes the scale of a tool. How do I maintain the tool grip Position when doing so?



sizeEvent.OnServerEvent:Connect(function(player, size)
	local character = player.Character or player.CharacterAdded:Wait()
	local backpack = player:FindFirstChildOfClass("Backpack")

	-- Function to scale the tool while maintaining handle position
	local function scaleTool(tool)
		if tool:IsA("Tool") and tool:FindFirstChild("Handle") then
			local handle = tool.Handle
			local originalSize = handle.Size

			-- Scale the tool
			tool:ScaleTo(size)
		end
	end

	-- Scale tools in the character
	for _, tool in ipairs(character:GetChildren()) do
		if tool.Name == "myNoob" then
			scaleTool(tool)
			break
		end
	end

	-- Scale tools in the backpack
	for _, tool in ipairs(backpack:GetChildren()) do
		if tool.Name == "myNoob" then
			scaleTool(tool)
			break
		end
	end
end)

you need to change the GripPos the same way you have the handle when you resize the tool, so the tool will still look like it’s in the right place in the players hand after its resized

sizeEvent.OnServerEvent:Connect(function(player, size)
    local character = player.Character or player.CharacterAdded:Wait()
    local backpack = player:FindFirstChildOfClass("Backpack")

    -- this is the function to scale the tool while handling the position and grip 
    local function scaleTool(tool)
        if tool:IsA("Tool") and tool:FindFirstChild("Handle") then
            local handle = tool.Handle
            local originalSize = handle.Size
            local originalGripPos = tool.GripPos

            -- this calculates the scale factor
            local scaleFactor = size / originalSize

            -- this scales the tool
            tool:ScaleTo(size)

            -- this adjusts GripPos to maintain positioning
            tool.GripPos = Vector3.new(
                originalGripPos.X * scaleFactor.X,
                originalGripPos.Y * scaleFactor.Y,
                originalGripPos.Z * scaleFactor.Z
            )
        end
    end

    -- this scales the tools in the character
    for _, tool in ipairs(character:GetChildren()) do
        if tool.Name == "myNoob" then
            scaleTool(tool)
            break
        end
    end

    -- this scales tools in the backpack
    for _, tool in ipairs(backpack:GetChildren()) do
        if tool.Name == "myNoob" then
            scaleTool(tool)
            break
        end
    end
end)